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

Hugh replied to Hugh's discussion Latest on Ning and iframes?
"Thanks for the reply. 
What I've always done is to take the YouTube code and paste it into html edi…"
11 hours ago
Kyryl_Ning_Support replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Hi Kevin,
Apologies for the inconveniences and thanks for the feedback.
We have informed the manage…"
12 hours ago
Kyryl_Ning_Support replied to Bizz ( John )'s discussion Is This A New Feature ?
"Hi John,
We don't wish to disappoint you but this option was available before. This option is prett…"
12 hours ago
Kyryl_Ning_Support replied to Hugh's discussion Latest on Ning and iframes?
"Hi Hugh,
I have run the test on my test network by using the code provided by Youtube here https://…"
13 hours ago
Kos replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Bryce chat, please, please, I'm grovelling, get chat released.........."
yesterday
David replied to David's discussion When are cancelled sites deleted?
"Thanks for the update, it's good to know it will eventually vanish."
yesterday
Kevin Acosta replied to Bryce Rubio's discussion A Follow-Up Message from our CEO
"Thank you for this venue to voice our issues and concerns as you plan and strategize upcoming enhan…"
yesterday
Kos replied to Hugh's discussion Latest on Ning and iframes?
"Absolutely they should.  File a ticket and get them on it.  Must be a new glitch"
yesterday
Kyryl_Ning_Support replied to Robert Sheen's discussion why is my Ning site unavailable?
"Hi there,
We have replied to you on the ticket that you have sent.
Best regards,
Ning Creators"
yesterday
Kos replied to Robert Sheen's discussion why is my Ning site unavailable?
"Sounds like they've deactivated you for some reason.  Contact them here.  Hope they get you up soon…"
yesterday
Carrie Robinson, Anthea Variend and Maureen Jansen joined Ning Creators Network
yesterday
Paul Corona replied to Robert Sheen's discussion why is my Ning site unavailable?
"we are having an issue with our site as well thought we're just getting and Unavailable message....…"
yesterday
Bizz ( John ) replied to Bizz ( John )'s discussion How To Add A Popular Blogs Module ( ver1 )
"Thanks Kos
I will add one for forums and articles as well as it works virtually the same."
yesterday
Kos replied to Bizz ( John )'s discussion How To Add A Popular Blogs Module ( ver1 )
"I think there are a lot of people who will love this tip.  Displaying the most popular 'anything' i…"
yesterday
Kos replied to Bizz ( John )'s discussion Enhance Your Social Channels Player ( All code I have used on my site )
"I wonder if Ning is taking notes.  *lol*   Thanks John!"
yesterday
Kyryl_Ning_Support replied to David's discussion When are cancelled sites deleted?
"Hi David,
Your network right now is on pending cancellation. The page that you can see at the momen…"
Monday
Kos replied to Diane Chojnowski's discussion Need help using CSS to change group owner
"That's fantastic!  That's the nice thing a/b having Creators here.  Sometimes it helps to just brai…"
Monday
Thisisbully replied to Bizz ( John )'s discussion Why I Have Been Adding A Lot Of Photos To My Site
"Nice finally"
Monday
Diane Chojnowski replied to Diane Chojnowski's discussion Need help using CSS to change group owner
"Thanks Jen for your brainstorming. We were able to fix the problem with a work-around.
We had the o…"
Monday
Tommy Gene and Kirsten Izatt joined Ning Creators Network
Monday
More…