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

Antonio Ancelmo Matos Santos replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"And who told you that I spoke to you? you are happy with the whole situation on Ning? good for you!…"
8 hours ago
Kos replied to John Bizley's discussion How To Add Some Design To Your: Pages Categories Nav, Groups Nav & Groups Pages Nav
"Sounds like a plan.  You know me.  I'll be lingering like an annoying cold.  LOL"
11 hours ago
Garfield Archivist replied to George H. Compton IV's discussion Ning coding and styling Tool "GeoPlugin" v2.00.003
"Awesome in every sense of the word."
13 hours ago
George H. Compton IV replied to George H. Compton IV's discussion Ning coding and styling Tool "GeoPlugin" v2.00.003
"Update 8/30/15, now you can also easily add HTML to the head or the body of your network.. TJ thank…"
15 hours ago
John Bizley replied to John Bizley's discussion How To Add Some Design To Your: Pages Categories Nav, Groups Nav & Groups Pages Nav
"Thanks Kos, will do but may hold off a little posting onto creators and just add them to my site as…"
21 hours ago
Kos replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Yes, much more clear"
23 hours ago
Kos replied to John Bizley's discussion How To Add Some Design To Your: Pages Categories Nav, Groups Nav & Groups Pages Nav
"Keep 'em coming John.  We appreciate it!"
yesterday
John Bizley replied to John Bizley's discussion How To Add A Little Separation In Activity Feed When Someone Comments On A Post
"Hi Anam, yes it's an all new site and profile for me here on creators. Joining will be available ve…"
yesterday
Anam replied to John Bizley's discussion How To Add A Little Separation In Activity Feed When Someone Comments On A Post
"Is this a different site to one I joined a while back where you posted tips? I checked out your new…"
yesterday
John Bizley replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Just made that change, I did split it up in two parts but this should help with any confusion now :…"
yesterday
Kos replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"At least I'm not the only one that got that wrong.  You may want to BOLD OUT and underline that are…"
yesterday
John Bizley replied to John Bizley's discussion How To Add A Little Separation In Activity Feed When Someone Comments On A Post
"Thanks for your kind words Anastasia, there are many others on here who provide excellent tips also…"
yesterday
John Bizley replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Thanks Garfield :-)"
yesterday
John Bizley replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Thanks Anastasia
That might be because you may have added the first part of code to your css and no…"
yesterday
Anastasia Grey replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Thanks John! That's Amazing for my Proyect. Just i wonder why i can't see " Feature Botton" Close…"
yesterday
Anastasia Grey replied to John Bizley's discussion How To Add A Little Separation In Activity Feed When Someone Comments On A Post
"Wow John! that's Great!  we finally have the best tips for ning 3 thanks to You!"
yesterday
Garfield Archivist replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"I can concur that as someone who spends quite some time on their site that 500 errors have been ver…"
yesterday
Kos replied to John Bizley's discussion NEW TIP: Tidy Up Title Links In Activity When Adding Lot's Of Discussions In Succesion
"Sharp; well done John"
yesterday
Garfield Archivist replied to John Bizley's discussion All New Photos Page Viewer Layout Code
"Beautiful display of photos"
yesterday
John Bizley replied to John Bizley's discussion How To Make Your Photos List Even On Both Side ( useful for those with full page width themes )
"I do have a few of these as when adding group modules they do the same thing in big and smaller col…"
Saturday
More…