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

Ryan O'Rourke replied to Ryan O'Rourke's discussion Need Help Adding Pinterest "Pin It" Button
"Hi, Tim.  Can you please elaborate on that?"
1 hour ago
Tim Atkinson replied to Ryan O'Rourke's discussion Need Help Adding Pinterest "Pin It" Button
"I've ended up using the AddThis features. Seems to work quite well with the site, and it (although…"
1 hour ago
Ryan O'Rourke replied to Ryan O'Rourke's discussion Need Help Adding Pinterest "Pin It" Button
"Yep ... that was one of the ones I tried already.  Contacted the guy over a week ago as well, to no…"
2 hours ago
Kos replied to Ryan O'Rourke's discussion Need Help Adding Pinterest "Pin It" Button
"I just did a search and wallah.  Any problems, I would contact the member who posted it. http://cre…"
10 hours ago
Fire-Tech replied to Kos's discussion OK Ning Wizards - I Need Your Help
"Just added. Much better! Thanks for sharing ;)"
11 hours ago
John Bizley replied to John Bizley's discussion 1940s Social Network Site Now Closed
"Thanks Tim and pleased my site had helped you in some way. No I will not be continuing the 1940s si…"
11 hours ago
Edie2k2 left a comment for Edie2k2
"Now Playing: Bill Withers"
11 hours ago
SweetPotato replied to Kos's discussion OK Ning Wizards - I Need Your Help
"Looking good."
11 hours ago
Tim Atkinson replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"I'm taking backups every day at the moment. Seeing all this about the Archives being buggy, am I wa…"
12 hours ago
Tim Atkinson replied to John Bizley's discussion 1940s Social Network Site Now Closed
"So sorry to hear that, John. If hadn't been for the evolution of the 1940s Social Network, I for on…"
12 hours ago
Kos replied to Kos's discussion OK Ning Wizards - I Need Your Help
"Yes that did it.  I'm still fiddling with tweaking a border but here's how it looks.  Thank you aga…"
12 hours ago
SweetPotato replied to Kos's discussion OK Ning Wizards - I Need Your Help
"Hi Kos
Yes, i just realised that the site I developed it on doesn't have other content instances on…"
14 hours ago
Ken Rich replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"Done - I forwarded your info - thanks."
14 hours ago
Strumelia replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"Crystal didn't need a crystal ball either.  ;D"
14 hours ago
Ken Rich replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"I have no idea, but thanks to their policy changes and future road map to nowhere, whoever is left…"
14 hours ago
Ken Rich replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"Thanks for another confirmation of the obvious. Greatly appreciated."
14 hours ago
Strumelia replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"Thanks Ken.  Please tell the programmers and powers that be over in JR to take a glance at my music…"
15 hours ago
Ken Rich replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"Understood. I am a non coder too but I'm managing. User friendliness is exactly what I'm pushing to…"
15 hours ago
JFarrow replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"I wonder how many of these folks still work for Mode/Glam/Ning"
15 hours ago
JFarrow replied to Ken Rich's discussion Ning Lied To Us - Your Content is Not Safe
"As a Ning for Hire i get at least 5 requests for help from new community managers every single week…"
15 hours ago
More…