Current status of the Ning Platform is always available on the Ning Status Blog.

Forum

Replies

  • NC for Hire

    Hi Andrew , there are two ways of doing this:

    1) Use jQuery .load() to load up the event page and get the total event number out , this approach is simple however it will slow down(a little) your site for loading up another page.

    2) Using a much complicated technique which requires a server to store that information, first we obtain the currently existing event count , then add a function to add event button to increase that count , the count information will be stored in database of a server outside of Ning. Then when user loads the home page , a script will retrieve the count information from the server then display it out on home page textbox. Well I don't recommend this approach as it involves a lot of work but this one does not increase your site loadtime as much as first approach.

    Assume that you want the total events (upcoming+past events) , so we need to get the data from

    http://yournetwork/events/event/listAllTypes

    So here is the FIRST approach code:

    HTML: use this code so that the script can inject the count into the span(of course , put this in your textbox)

    <span id="eventcount"></span>


    You can put content in front of it like :

    Total Events: <span id="eventcount"></span>

    Now the script(put this in custom code):

    <script type="text/javascript">

    //coded by Elson Tan (@elsodev) elsodev.com
     var ecount = '0';
    if(x$('span#eventcount').length){
          
    //event count span exists
    x$('#xn_bar').before('<div id="ecountstore" style="display:none;width:0px;height:0px;"></div>');
    //we load up that page and put the html into an invisible box
    x$('#ecountstore').load('events/event/listAllTypes .xg_span-12 ul', function(){
    x$('#ecountstore ul li a').remove();
      x$('#ecountstore ul li').each(function(){
          var tempstore = x$(this).text();
          //we remove brackets from the each numbers
           var getecount = tempstore.replace(/\((.*?)\)/g, '$1');
         //we add it up to obtain a total
           ecount = parseInt(parseFloat(ecount) + parseFloat(getecount));
      });
    //after each function done , we display out the total
    x$('span#eventcount').html(ecount);
    });
    }
    else{
    }
    </script>

    There are a few things in the script that you may not understand:

    •        var getecount = tempstore.replace(/\((.*?)\)/g, '$1');

    This is to remove the brackgets using regex , you can learn more about it here , its awesome for matching things

    •        ecount = parseInt(parseFloat(ecount) + parseFloat(getecount));

    This is adding up to get the total value , I used parseFloat to turn it into an floating point integer , this might be new to you. What it does is to make your integer able to undergo calculation properly. Normally if you don't use parseFloat , javascript will turn 2+1 into 21 , while using parseFloat 2+1 =3 . You can learn more about it here

    That's it , hope it helps. I havent tested the code , just roughly coded , I hope it works.

  • NC for Hire

    TJ's script only gets the upcoming events count with brackets, not all existing events sum/total.

  • Thats cool...actually, I am only interested in the upcoming events. thanks guys.

This reply was deleted.

Search the Creators Network

Latest Activity

Nomen Nescio left a comment for Nomen Nescio
"Anyone figured out how to do an "Ello" style invitation only network? Just curious."
2 hours ago
Rowald replied to Ning's discussion Update to Product Roadmap and Communication Changes
"Yes."
2 hours ago
Traddie replied to Traddie's discussion Help - Problem with Archiver
"Thanks Stumelia. That worked.
The next problem is that when I downloaded the media files for my Blo…"
3 hours ago
Strumelia replied to Traddie's discussion Help - Problem with Archiver
"did you try-   x the close box and close the archiver program using top right liitle x box, then re…"
9 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"cant tell ya how much i appreciate this !
was stressed out for days trying to figure this out dont…"
10 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
""
10 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"wait i did it !!!! dude this is great thank you soo much man "
10 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"hmm ok i think i have this figured out i copied the code and input my src code ,  i see the chatwin…"
11 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"ok now i feel silly ...i dont think i have a ning bar ? i have ning 3.0 http://metaldevastationradi…"
11 hours ago
Fire-Tech replied to Nancy Marsh's discussion Suggestions for Broadcast Message Archive
"Here's a discussion on what I do."
12 hours ago
Kos replied to Nancy Marsh's discussion Suggestions for Broadcast Message Archive
"I made a "category" in the Forums for "Site News" so that each newsletter is stored within the cate…"
16 hours ago
Nancy Marsh replied to Nancy Marsh's discussion Suggestions for Broadcast Message Archive
"Sorry, I posted prematurely.
I was starting to say that the site is private.
Thanks"
16 hours ago
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"wow George you rule dude ! thank you man ! to hell with spot.im i am gonna do this "
17 hours ago
Garfield Creator replied to Zachary Moonshine's discussion Floating widget help ?
"Just want to say I have a lot of respect for someone who is willing to spend "a couple of hours" on…"
22 hours ago
George H. Compton IV replied to Zachary Moonshine's discussion Floating widget help ?
"I spent a couple hours updating the code. :-) It's now fully responsive and I also added a chatwing…"
yesterday
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"WOW that looks killer , i had started using spot.im too but most of my users already are used to th…"
yesterday
George H. Compton IV replied to Zachary Moonshine's discussion Floating widget help ?
"Here's all the code you need to have it working perfectly. See image below. It's awesome. Chatwing…"
yesterday
Ceddy J replied to soaringeagle's discussion hmm interesting careers at ning/mode
"That's how I feel man. This is a great analysis. Ning takes a long time with updates, but never thi…"
yesterday
Kos replied to James Hollins's discussion Ning site is full of pop ups
"Mine are back up.  Were you able to resolve your pop up issue?"
yesterday
Zachary Moonshine replied to Zachary Moonshine's discussion Floating widget help ?
"<div id="chatwing-embedded-1d973543-c11b-48d4-9e52-544915bd6a0f"></div>
  
THIS IS THE CODE FOR MY…"
Saturday
More…