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

doone replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"Ning still works, at least.  If you have a Ning 3 or a custom Ning 2 it is not that bad, IMO.  It w…"
2 hours ago
Tu Thai, Roger Crawford, keila and 1 more joined Ning Creators Network
8 hours ago
Katcha Sanderson replied to Katcha Sanderson's discussion Multiple forums in single network?
"Thanks for the realistic feedback. I wanted to know what my network can and cannot do in regards to…"
9 hours ago
JFarrow replied to David Carr's discussion Going to spam
"sometimes you can accidentally mark a message spam in gmail and all will go to spam... go to your s…"
9 hours ago
Kos replied to David Carr's discussion Going to spam
"It seems to happen, depending on the users security settings.  I'm always having to tell people to…"
9 hours ago
Paul Asher replied to James Quack's discussion Not able to Import Forums into Buddypress from Ning .JSON FIles
"No probs. Hope WP works out for you but if it doesn't don't forget Jamroom ;-)"
11 hours ago
James Quack replied to James Quack's discussion Not able to Import Forums into Buddypress from Ning .JSON FIles
"Thanks Yin. I will contact them.

And thats to you too Paul! That is a greattttt TIp"
12 hours ago
Paul Asher replied to James Quack's discussion Not able to Import Forums into Buddypress from Ning .JSON FIles
"Remember that by default Ning only archive a maximum of 200 comments per item. I think you have to…"
15 hours ago
SweetPotato replied to Katcha Sanderson's discussion Multiple forums in single network?
"I'd use groups in Ning 2.0. Three separate groups each with their own forum. Sadly, there is no way…"
20 hours ago
dave replied to George H. Compton IV's discussion (tip for 3.0) floating navigation menu & ningbar -- two code formats to choose from HTML or CSS
""
yesterday
Kos replied to Katcha Sanderson's discussion Multiple forums in single network?
"2.0 does not allow it.  3.0 does (allow for multiple forums).  Sadly Ning has suspended migrating f…"
yesterday
Writer Chick {Diane} replied to Crystal's discussion Welcome to Creators 3.0!
"If you can't access your network because of domain setting errors, use the link below. That will gi…"
Sunday
Writer Chick {Diane} replied to Satheesh Kumar's discussion Change in Domain Name
"If you can't access your network because of domain setting errors, use the link below. That will gi…"
Sunday
Kwan Yin replied to James Quack's discussion Not able to Import Forums into Buddypress from Ning .JSON FIles
"Hi James,
I'm doing the same thing, slowly moving from Ning to wordpress / buddypress.
I can thorou…"
Saturday
Garfield Archivist replied to Crystal's discussion Welcome to Creators 3.0!
"Ok, if you would like me to take a look send me a private message. However, even looking at all you…"
Saturday
Phyllis Freeeman replied to Crystal's discussion Welcome to Creators 3.0!
"Thanks for the help Garfield.  My ning site is just a portion of a larger website that I run.  It w…"
Saturday
Garfield Archivist replied to Crystal's discussion Welcome to Creators 3.0!
"I'm not sure what your specific situation is I'm sorry to say. I am trying to reread what you have…"
Saturday
Phyllis Freeeman replied to Crystal's discussion Welcome to Creators 3.0!
"Problem is that my network went down when I migrated my website to a new server.  I can't login to…"
Saturday
Garfield Archivist replied to Garfield Archivist's discussion Network Creators Private Survey Results
"Sunday July 26, 2015
Last day to fill out our private anonymous survey and therefore receive a repo…"
Saturday
SweetPotato left a comment for Alexander
"Hi Alexander, thanks for the interest in working with me. Unfortunately, I am not available for fre…"
Saturday
More…