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

Kos replied to Trish White's discussion TEXT BOX NOT WORKING AGAIN
"Design Studio - Custom CSS area
None in there?"
10 minutes ago
Caron Jane Lyon / Katie Reve left a comment for Ron
"Hi Ron, Can you give me a summary of where Ning is at? Re 2.0 3.0? I have several networks all crea…"
29 minutes ago
fabiola replied to soaringeagle's discussion ning vs jamroom
"Hello soaringeagle 
I appreciate your valuable information.  Few weeks ago I found out about the "p…"
2 hours ago
Ron replied to Luke Jones's discussion Cometchat are going to be the ones to save Ning
"yes, just as I thought. thanks."
5 hours ago
Anant Garg replied to Luke Jones's discussion Cometchat are going to be the ones to save Ning
"Thank you for your feedback. Yes, we are working on making our website clearer. 
Regarding the temp…"
6 hours ago
Ron replied to Lakhassia's discussion How to upgrade to 3.0 to 2.0
"Hey Lakhassia, I'm not sure you can call that an upgrade and Ning doesn't serve "new" 2.0 networks…"
6 hours ago
Fire-Tech replied to Luke Jones's discussion Did anyone even want Ning 3.0? ,
"Yup"
10 hours ago
Strumelia replied to Luke Jones's discussion Did anyone even want Ning 3.0? ,
"Will things ever go back to some form of the way they were? Glam is the only one that can answer th…"
11 hours ago
Lakhassia left a comment for Lakhassia
"Thank you both. "
11 hours ago
Fire-Tech replied to Mary Jane Peterson's discussion New Site with 3.0
"+1 lol"
11 hours ago
Fire-Tech replied to Luke Jones's discussion Did anyone even want Ning 3.0? ,
"Diane pretty much summed it up.
Many of us had pushed 2.0 to its limits and the features we did hav…"
11 hours ago
Writer Chick {Diane} replied to Mary Jane Peterson's discussion New Site with 3.0
"I wonder if they even care what content is on their platform anymore, since they don't seem to care…"
14 hours ago
Writer Chick {Diane} replied to Luke Jones's discussion Did anyone even want Ning 3.0? ,
"To answer your question in the title line honestly....YES, there were (and still are) creators who…"
14 hours ago
Trish White replied to Trish White's discussion TEXT BOX NOT WORKING AGAIN
"Hi Kos,
I haven't added any Css code - I do what I always do - nothing different - I also don't kno…"
16 hours ago
Jorge Vila replied to marshall blake's discussion Events For 3.0 Networks
"Marshall, thanks a lot for sharing this! I really appreciate it. I would like to join your communit…"
16 hours ago
Eve Bellator replied to Mary Jane Peterson's discussion New Site with 3.0
"Agreed! They asked me to clean up or shut down my Gas Mask site because of nudity. I shut it down.…"
16 hours ago
Jorge Vila replied to marshall blake's discussion Events For 3.0 Networks
"Robin,
Do you have Time.ly installed in your site? If yes, may I see it?
Jorge Vila"
17 hours ago
steve replied to Mary Jane Peterson's discussion New Site with 3.0
" You need to be careful Jane if you are running some sort of sex toy party thing... Ning are a bit…"
17 hours ago
Kos replied to Trish White's discussion TEXT BOX NOT WORKING AGAIN
"Trish it must have something to do with the code you have added.  It's not happening to us so if I…"
18 hours ago
Valerie commented on Crystal's blog post Migration to Ning 3.0 - Demo and Q&A Recording
"What's the cut off date to migrate to 3.0? Sorry but I don't want to have to read through a ton of…"
19 hours ago
More…