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

Jenny Jo Bingham, Creativos Latma and Ana Vaz joined Ning Creators Network
15 minutes ago
Ron replied to Urban Pulse Media's discussion RSS Feed Not working
"Hey Urban Pulse Media,
Your best option here is to contact Ning support as this is static content a…"
51 minutes ago
John Bizley replied to John Bizley's discussion First Look Of My New Classifieds Page now open for viewing. Updated 30/03/15
"NAVBAR MENU UPDATE
Updated the Navmenu to remove all the options and only show the one you are actu…"
57 minutes ago
Ron replied to Jan Homan's discussion How to create a video as a header?
"thanks :)"
1 hour ago
Ron replied to Jan Homan's discussion How to create a video as a header?
"Hey Jan, you're welcome. glad you got this to work now :-)
You can try adding autoplay and loop opt…"
1 hour ago
Jan Homan replied to Jan Homan's discussion How to create a video as a header?
"And I have accepted your friendship ;)"
1 hour ago
Jan Homan replied to Jan Homan's discussion How to create a video as a header?
"I have put the code into the footer and guess what... It worked!
May I ask you about this code with…"
1 hour ago
Ron replied to Jan Homan's discussion How to create a video as a header?
"The latest code I sent you looks ok, unless you have something in mind. Here's a screenshot of the…"
2 hours ago
John Bizley replied to John Bizley's discussion Updated Videos Page: ( code now available )check it out and if all looks good will post the code etc
"Should be good to go now, you may need to refresh your browser to see the tab."
2 hours ago
John Bizley replied to John Bizley's discussion Updated Videos Page: ( code now available )check it out and if all looks good will post the code etc
"Thanks Thiago will check that out, might have done that by mistake."
2 hours ago
Thiago Santos de Moraes replied to John Bizley's discussion Updated Videos Page: ( code now available )check it out and if all looks good will post the code etc
"John, this page is now private."
3 hours ago
John Bizley replied to John Bizley's discussion Creating a ' Tag Cloud ' on your pages
"Thanks Thomas :-)"
3 hours ago
John Bizley replied to John Bizley's discussion First Look Of My New Classifieds Page now open for viewing. Updated 30/03/15
"Just made an update to this for the design of the category links. They have also a nice hover colou…"
3 hours ago
Jan Homan replied to Jan Homan's discussion How to create a video as a header?
"This is my design screen"
6 hours ago
Jan Homan replied to Jan Homan's discussion How to create a video as a header?
"The space which contains my header image is the space called:
<div class=''site-header container''…"
7 hours ago
Mary Jane Peterson replied to Mary Jane Peterson's discussion Need Some Ideas For New Site
"Hi steve  

Thank you so much :)"
7 hours ago
Jan Homan replied to Jan Homan's discussion How to create a video as a header?
"I put the code script into the custom code space and saved it, but there is nothing to see on the p…"
8 hours ago
Thomas Hoey replied to John Bizley's discussion Creating a ' Tag Cloud ' on your pages
"Great tip, John. Perfect for article and blog pages. Thanks."
9 hours ago
M.Tariq Malik replied to M.Tariq Malik's discussion Policy Breach Notice.. Help Required
"TJ @ jQueryHelp please help me ...
I have resolved one issue by removing email verification. But pl…"
9 hours ago
Ron replied to Jan Homan's discussion How to create a video as a header?
"ok sorry, I thought you know how to enclose a script already. Anyway, try this again with the attac…"
14 hours ago
More…