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

Poppili left a comment for Poppili
"Thanks Jamie 
Please send me an email to contact@mumaround.com
Thanks a lot"
35 minutes ago
Jim Kinson replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"George, this is awesome as usual. Why did we even have to do this 3.0 thing. They could have hired…"
3 hours ago
Jamie Baker left a comment for Poppili
"Hi,
I see your looking for some design help. Drop me a message if your stuck.
Jamie"
4 hours ago
steve replied to Neil Norton's discussion No notifications equals slow death for groups
"The last time this was mentioned it was pointed out that inline notification wont be included in Ni…"
6 hours ago
Fire-Tech replied to Anant Garg's discussion CometChat Network Edition now available for NING
"Just installed and have to say that first impressions are great! Notifications and file uploads are…"
9 hours ago
steve replied to Theresa Happe's discussion Looking for someone to switch my site for ning 3.0
"I think the reality is, it doesn't much matter when you compare N2 to N3, the fact is N2 is being d…"
9 hours ago
United Spirits replied to Traddie's discussion Does any member have Code to add "views" to a page
"Freehostedscripts gives you the ability to show whose online two."
16 hours ago
United Spirits replied to United Spirits's discussion Alternative Text Editor
"This makes me pretty excited. The default Text editor just I don't really like it. I just hope it w…"
16 hours ago
United Spirits replied to Theresa Happe's discussion Looking for someone to switch my site for ning 3.0
"Ning 3 is better for designers. Fine grain controls are its selling point. Ning 2 is better for fix…"
16 hours ago
Jen replied to Willerie Razote's discussion CSS Advice: How to change the title to buttons
"It was such a small bit of help. =) Thank you, Willerie!"
yesterday
Bernard Lama replied to Traddie's discussion Does any member have Code to add "views" to a page
"Hi Traddie,
You can use the code from here http://www.hitwebcounter.com as I'm using the same here …"
yesterday
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 ;)
"hello Scott.. Sure that should be a simple thing I'll work on it Monday and get back to you as soon…"
yesterday
Simon Farnworth replied to Ceddy J's discussion Quick Add Feature For Activity Feed?
"Wow! How did you do that??"
yesterday
George H. Compton IV replied to United Spirits's discussion Alternative Text Editor
"SP I've been really busy this weekend I'll try to work out the CSS Monday.
Even though I'm sure you…"
yesterday
Willerie Razote replied to Willerie Razote's discussion CSS Advice: How to change the title to buttons
"@Jen--echoing Joanna, you are AWESOME!  Helpful and always on point!"
yesterday
Jen replied to Willerie Razote's discussion CSS Advice: How to change the title to buttons
"@Joanna, Goodness, made my day. Thanks, happy it helped a tiny bit."
yesterday
Poppili left a comment for vaqz
"Hi
Please send me an email to contact@mumaround.com
I am looking to hire a ning developer"
yesterday
SweetPotato replied to Traddie's discussion Member Map Not Working
yesterday
Joanna replied to Willerie Razote's discussion CSS Advice: How to change the title to buttons
"Jen - as usual, you're awesome. Thanks.
I had the same problem."
yesterday
Magesoad replied to Theresa Happe's discussion Looking for someone to switch my site for ning 3.0
"I managed to leave my perfect 3.0 network and all the features it suits me, so do not have to compl…"
Saturday
More…