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

Bizz ( John ) replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"Unless I am mistaken it looks like this has been fixed today. ( Sat 25/03/17 )"
2 hours ago
Thisisbully replied to Mike Collins's discussion Ning Development - Roadmap
"a lot of stuff has been added they just didn't post it yet .For instance the comment wall in groups…"
6 hours ago
Alliance replied to Mike Collins's discussion Ning Development - Roadmap
"i agree a roadmap from April would be appreciated if you could. It gives us time to decide on work…"
21 hours ago
Kos replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"Yes sir"
yesterday
Bizz ( John ) replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"Kos I agree. Normally I am quite a patient person as I know writing code can take time with testing…"
yesterday
Kos replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"I was going to respond but felt I'd leave it to you John.  This is just insane!  You don't release…"
yesterday
Bizz ( John ) replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"I'm sorry, but why would a feature you have added that isn't working correctly not be a priority to…"
yesterday
Suki Winthrop replied to Bizz ( John )'s discussion What's Happened To The Activity Feeds ? None are showing on any sites including creators
"now my posts from 3weeks ago areshowing up as new posts  in Creator activity feed.  What the?"
yesterday
Suki Winthrop replied to Bizz ( John )'s discussion Why Are The Events Not Listing The Same Way As UpComing In My Events Or Categories ?
"So Events is the ONE new feature - aside from Google Capture,which you didn't create- that has been…"
yesterday
Beatriz Martín replied to ⚡JFarrow⌁'s discussion Clean, Robust, Filterable Community Member Directory
"But. If someone looks the source code (html) and search for the specific line of the awesome-table,…"
yesterday
Douwe Dronkert replied to Douwe Dronkert's discussion Can I just upgrade to Facebook Graph API v2.3 or higher?
"Hi Kyryl,
Thanks for your quick reply.
That's a pity. Is this kind of functionality something that…"
yesterday
Kyryl_Ning_Support replied to Yana Ning Support's discussion CAPTCHA - NO BOTS AND SPAMMY CONTENT
"Hi Kevin,
Former network creator has to fill the form http://hc.ning.com/contact/transferownership/&hellip;"
yesterday
Kyryl_Ning_Support replied to Yana Ning Support's discussion CAPTCHA - NO BOTS AND SPAMMY CONTENT
"Hi Anam,
We do apologise for the inconveniences.
The report has been created and passed to our tech…"
yesterday
Anam replied to Bizz ( John )'s discussion What's Happened To The Activity Feeds ? None are showing on any sites including creators
"Yes mine has been gone for 2 days and i have just filed ticket. I don't understand why there could…"
yesterday
Suki Winthrop replied to Yana Ning Support's discussion CAPTCHA - NO BOTS AND SPAMMY CONTENT
"Why does the Latest Activity feedhere on Creators now only show Ning's own Facebook posts ?!?
Pleaz…"
yesterday
More…