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 Video Issues Again For Embed Videos Showing Blank Box
"When is this going to be fixed? Been a while now as it's not just the image not displaying ( by the…"
3 hours ago
Kos replied to Thisisbully's discussion Chat is available on 3.0
"Kryrl I could be speaking too soon (hope not!) but it appears someone did something b/c Chat is now…"
12 hours ago
Kyryl_Ning_Support replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Hi Steve,
We are sorry to hear that you are experiencing such an issue but you can control the orde…"
14 hours ago
Kyryl_Ning_Support replied to Ian's discussion Side Backgound Image keeps shrinking and orienting left & animated gif header isn't working
"Hi there,
We are sorry for the inconveniences, and yes you are right this issue isn't connected wit…"
15 hours ago
Oleksii is now a member of Ning Creators Network
15 hours ago
Steve C replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"I'm having a HUGE problem with blog comments on my Ning 2 site. It used to be that blog comments po…"
yesterday
Ning via Facebook

#inspirewithNING #success Explore new horizons with NING and NING Creators Network! Find your…

Bizz ( John ) replied to Bizz ( John )'s discussion Videos Playing In Activity Feed, check it out on my site ( Updated: 19-04-17 )
"Would be interested to hear if anyone has tried this and encountered any problems. Works fine for m…"
Friday
Bizz ( John ) replied to Annabel Gregory's discussion Events on Ning3
"Glad to help for a temporary fix until Ning adds this option. By the way if you want to see it work…"
Friday
Annabel Gregory replied to Annabel Gregory's discussion Events on Ning3
"Thanks, John - I will try your tip. I do hope Ning will make this unnecessary soon, though!"
Friday
Annabel Gregory replied to Annabel Gregory's discussion Events on Ning3
"Thank you, Kyryl, I look forward to hearing from you."
Friday
Bizz ( John ) replied to Annabel Gregory's discussion Events on Ning3
"Hi Annabel
I just created a small tip for this so members do not have to add an image
Events Defaul…"
Friday
Paul Corona replied to Ian's discussion Side Backgound Image keeps shrinking and orienting left & animated gif header isn't working
"Images recently have been a royal pain.  I resolved my background image issue on my profile, but we…"
Friday
Ning via Facebook

#createwithNING #design Colourful design is the highway to network popularity. Check NING…

Bizz ( John ) replied to Bizz ( John )'s discussion Custom code being blocked by browsers unless your signed in!
"Thanks for the reply Kyryl and testing this out. No nothing special within them just a list of link…"
Friday
Kyryl_Ning_Support replied to Marcelo Rodrigues's discussion Network stability issues
"Hi there,
Thanks, for additional information, however when I have checked your network the issue ha…"
Friday
Kyryl_Ning_Support replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Hi there,
Thanks for the explanation. And here is the good news for you, we already have had the su…"
Friday
Kyryl_Ning_Support replied to Bizz ( John )'s discussion Custom code being blocked by browsers unless your signed in!
"Hi John,
Just checked the code with two html boxes on the main page and the script working properly…"
Friday
Badan Barman replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Dear Kos, Yes I know there are ways to put ads in between blog post, forum and others but my point…"
Friday
Badan Barman replied to Anastasiia_NING support's discussion Ning 2Q 2017 plan!
"Dear Kyryl,
Thank you for reading the comment and forwarding it to the management. It is a much nee…"
Friday
More…