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

Aleman Chandrasekar is now a member of Ning Powered Events
15 hours ago
Gerry Emery and Anna Semendiaieva joined Ning Creators Network
yesterday
Hugh replied to The Ning Team's discussion Network Accessibility Update II
"Thanks Kos. The issues resolved themselves later that day, Functionality returned bit by bit. It wa…"
yesterday
Kos replied to The Ning Team's discussion Network Accessibility Update II
"Hugh just seeing this now.  Wow, you're going through a boatload of issues.  Have you cleared your…"
yesterday
mark gardner and Rafael Marchesi joined Ning Creators Network
yesterday
Rowald replied to Anthony Reardon's discussion What is Ning?
"Great post and good to see you here Anthony!"
yesterday
Hugh replied to The Ning Team's discussion Network Accessibility Update II
"I've been reporting problems with my broadcast messages failing to reach all members for a couple o…"
Wednesday
Hugh replied to The Ning Team's discussion Network Accessibility Update II
"As of this morning, all my backend functionality doesn't work. So far I've discovered that I cant:…"
Wednesday
Giovanni Cappai replied to Giovanni Cappai's discussion Need your Feedback!
"Really appreciate it! do you have any other suggestions to improve my network design? I'd love to h…"
Tuesday
George H. Compton IV replied to Giovanni Cappai's discussion Need your Feedback!
"Sorry I wasn't wearing my glasses yesterday when I post this. Here's the code without the extra scr…"
Tuesday
Cat replied to The Ning Team's discussion Network Accessibility Update II
"I disliked 3.0 also, Happy, and will have to find a new platform, if 2.0 stops being supported."
Tuesday
George H. Compton IV replied to George H. Compton IV's discussion Add Google translate to all pages. Any network not just Ning networks!!!
"Update 11/28/16 -- Google translate v12 - All languages. You no longer have to select a default lan…"
Monday
Mustaien is now a member of Ning Creators Network
Monday
Jen replied to The Ning Team's discussion Network Accessibility Update II
"Yes. It's just a simple HTML Text Box to add something about yourself, like an intro. Ning 2.0 offe…"
Monday
Hippy replied to The Ning Team's discussion Network Accessibility Update II
"all I have to say is if you do quit supporting 2.0 you can quit looking for my payment each moth ,…"
Monday
Giovanni Cappai replied to Giovanni Cappai's discussion Need your Feedback!
"Hi George! thanks for your help and yes, i found your tip so cool that i dove into it immediately :…"
Monday
Brian Antezana replied to The Ning Team's discussion Network Accessibility Update II
"Yikes!"
Monday
Just Asking replied to J.Ayvar's discussion Our Ning Account has been hacked.
"Where is there more information on this? How do you know the scope of it?"
Sunday
J.Ayvar replied to J.Ayvar's discussion Our Ning Account has been hacked.
"We Have a name and e mail . Wi Will report to Fbi <a rel=nofollow href="https://www.ic3.gov/compla&hellip;"
Sunday
Thisisbully replied to The Ning Team's discussion Network Accessibility Update II
"Do you use ning 3 on mobile like an actual cellphone? If so you will feel my pain ,from the tip or…"
Sunday
More…