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

John Bizley replied to John Bizley's discussion My New Media Centre Including Music
"Thanks Zachary
The main page is just a custom page using the wide top and two columns beneath, all…"
7 hours ago
John Bizley replied to John Bizley's discussion Added My 'Facebook Style' Layout To My Demo Site For Photos
"Thanks Zachary
I will add all the code etc into my demo site once I finish a few tweaks here and th…"
7 hours ago
Zachary Moonshine replied to John Bizley's discussion Added My 'Facebook Style' Layout To My Demo Site For Photos
"now that is cool man puts the photos big and up top so you can see them and puts comments on the si…"
8 hours ago
Strumelia replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"I'm not having any problems either, in windows/firefox nor Mac/safari."
21 hours ago
Zachary Moonshine replied to John Bizley's discussion My New Media Centre Including Music
"this looks awesome man i love the layout for this very clean and everything is available "
21 hours ago
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"yeA its weird its random it happens a whole lot just not every time"
yesterday
Kos replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"That's odd.  It never happens to little old me.  (good luck for a change)"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"see that time i typed i b4  the editor loaded tyoed the rest and it didnt send
i said i have reinst…"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"i"
yesterday
Kos replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"Check your browser or run a scan bro.  I've had no problems here at all (FF)"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"site builder will be perfected by then if u read my tip on how i built the front page forum display…"
yesterday
Kos replied to Rob Nanya's discussion Any simple way to put the site offline?
"Ning had that in 2.0 but hasn't implemented it in 3.0.  At the rate things are going, I'll be in a…"
yesterday
Kos replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"Guess I'll have to make more time to re-visit JR.  Maybe after the holidays.  Just too crazy right…"
yesterday
Zachary Moonshine replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"im gonna sign up in there site so i can start talking to them and see what they can do for me as we…"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"yes exactly  its very good choice  the music is an add in n but they were orifginakly gesared towar…"
yesterday
Zachary Moonshine replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"jamroom may be a good spot to stick my radio in the future if ning does not work out after checking…"
yesterday
Strumelia replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"Each of the 3 has its strengths and non-strengths.  No one choice fits all."
yesterday
Zachary Moonshine replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"i want music as a plugin to the site but not its main focus i am more interested in having somethin…"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"bad pr
look at how frackings  screwing up the environment   like crazy but then exxon puts out an a…"
yesterday
soaringeagle replied to soaringeagle's discussion ning to jamroom just got eassier and more powerful
"why those when jamrooms built for music at its core"
yesterday
More…