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

Joe replied to Joe's discussion What Happened to NING?
"i sent a ticket some weeks ago about my concerns and I remained with no reply
it is not nice that w…"
7 hours ago
Strumelia replied to Strumelia's discussion Screenshots comparing my OLD and my NEW Network
"Thanks... and throwing some sunshine at some of the folks here who have been kind and supportive to…"
10 hours ago
Alessandro replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
"Thanks George, but you don't need to take your time on writing a new code for me. I asked just in c…"
10 hours ago
Strumelia replied to PeruCool's discussion Alternatives to Ning social network
"Some screenshots of my old and new sites, of interest to those in this thread:
http://creators.ning&hellip;"
10 hours ago
Strumelia replied to FedMedic's discussion Jamroom Question
"Some screenshots of my old and new sites, of interest to those in this thread:
http://creators.ning&hellip;"
10 hours ago
Strumelia replied to soaringeagle's discussion ning vs jamroom
"Some screenshots of my old and new sites, of interest to those in this thread:
http://creators.ning&hellip;"
10 hours ago
Strumelia replied to Paul Asher's discussion Ning3 Member CSV File
"Some screenshots of my old and new sites, of interest to those in this thread:
http://creators.ning&hellip;"
10 hours ago
Strumelia replied to Joe's discussion What Happened to NING?
"Many have left or are leaving. Others are staying and just hoping for the best. You'll get no solid…"
11 hours ago
George H. Compton IV replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Thank you Jim. :-)  Sorry I missed your call today. Tomorrow's going to be very busy for me here at…"
11 hours ago
George H. Compton IV replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
"Alessandro, I'm sorry I just went to that tip the links on that tip are not working either.  So you…"
12 hours ago
Alessandro replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
"Thanks George!"
15 hours ago
George H. Compton IV replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
"Hello Alessandro, I'm not sure what happened to that tip but here's a link to version 2.1.   If th…"
18 hours ago
George H. Compton IV replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Good morning  lorianne, :)  I was just on your network and noticed a couple minor issues. I wrote s…"
18 hours ago
Alessandro replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
"Hi George,
You mentioned at the end of the post links to a similar tip you wrote for Ning 2.0, but…"
19 hours ago
lorianne replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"yyyayy! nevermind. figured it out by trying some of the other codes you offered within comments for…"
20 hours ago
Jorge Aguilar is now a member of Ning Networks en español
22 hours ago
Poppili replied to Paul Asher's discussion Ning3 Member CSV File
"very clear thanks again Paul"
yesterday
lorianne replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"i tried also removing some modules from columns, thinking something was too large & was pushing the…"
yesterday
lorianne replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Hi George -   OK, so i wanted this badly enough that I decided to just go for it.  I stripped out A…"
yesterday
Strumelia replied to Paul Asher's discussion Ning3 Member CSV File
"I used this Jamroom tool when I went live from my ning to my Jamroom site.  The JR tool sent all 48…"
yesterday
More…