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

Luke Jones replied to Luke Jones's discussion Just another quick question
":) I've just done it now :) I've been trying to change the colour for ages aha, Alright awesome :)…"
3 minutes ago
Scarlett replied to Luke Jones's discussion Just another quick question
"No Problem Luke, by the way I just made a photo page public so you can see how the like buttons loo…"
9 minutes ago
Luke Jones replied to Luke Jones's discussion Just another quick question
"Ah that's Awesome :) Thanks very much Scarlett :) "
26 minutes ago
Scarlett replied to Luke Jones's discussion Just another quick question
"Hi Luke
The likes button is linked to your links setting within the design studio so to get it to h…"
32 minutes ago
soaringeagle replied to soaringeagle's discussion ning to jamroom ease of use meets power flexibility and unmatched support with instruction video
"your welcome
it was my pleasure
been wanting to do it for awhile now
but since its easier,..and mor…"
10 hours ago
Strumelia replied to soaringeagle's discussion ning to jamroom ease of use meets power flexibility and unmatched support with instruction video
"Thanks for taking the time and effort SE, it's appreciated."
11 hours ago
JFarrow replied to John "JC" Colyer's discussion Has anyone heard the rumour ning is going out of businesss?
"this is i believe the second place i have read this by you JC.... it would help if you pointed us t…"
11 hours ago
JFarrow replied to John "JC" Colyer's discussion Is ning going out of business in 2015?
"I have seen no direct indication of this, but of course this is how rumors get started"
12 hours ago
Strumelia replied to John "JC" Colyer's discussion Has anyone heard the rumour ning is going out of businesss?
"I suspect it's not so much that there are 'rumors'- more likely it's just that people have been pos…"
15 hours ago
soaringeagle replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"just another way nings screwed us and jr cameto the rescue (too late for me as im live but jr fixed…"
15 hours ago
María José Flores, Michael Nguyen, Michelle Weber and 1 more joined Ning Creators Network
20 hours ago
Kos replied to John "JC" Colyer's discussion Has anyone heard the rumour ning is going out of businesss?
"No.  There are numerous site owners concerned that Ning has not issued any new releases or updates…"
20 hours ago
Strumelia replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"I second what SP said-  I really enjoyed listening to you- feel like i know you a little better now…"
yesterday
soaringeagle replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"and thats how i took it ;)"
yesterday
SweetPotato replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"I meant it in a good way -:)"
yesterday
soaringeagle replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"been working so damn hard on this site with so lil sleep the 1st version of the vid i kept forgetti…"
yesterday
SweetPotato replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"Very cool.
I gotta say this: you speak completely differently from how you write. It's like two dif…"
yesterday
soaringeagle replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"why thank you dear
:)
the 1st versiondidnt come out well and i was rambling lil too much haha"
yesterday
Strumelia replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"I gotta say that is really a clear and helpful video, Soaring.
It's sure gonna help me a whole lot,…"
yesterday
soaringeagle replied to Ken Rich's discussion Ning to Jamroom - An Empowering Migration Path...
"i just made a vid introducing the ease as well as power of jr
u can edit the 1st post with the embed"
yesterday
More…