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

Shadow replied to The Ning Team's discussion Acquisition Update
"Very troubling to see we have several about to shut their sites due to new prices by Oct 1 and NING…"
4 hours ago
Suki Winthrop replied to The Ning Team's discussion Acquisition Update
"Maybe Ning just dropped in to see what condition their condition was in.
Garfield- spot on.  Making…"
10 hours ago
Garfield Archivist replied to The Ning Team's discussion Acquisition Update
"Ning's effectiveness in making this announcement is currently 100% equal to someone who just plain…"
10 hours ago
jennifer huntelman replied to amrit B's discussion Ning 2.0 network with more than 1850 members for sale
"If it is still up for purchase perhaps we could talk"
12 hours ago
Janice D Carter replied to The Ning Team's discussion Acquisition Update
"I agree"
13 hours ago
Garfield Archivist replied to The Ning Team's discussion Acquisition Update
"Click the link above to become confused. This says nothing about this present situation with Ning.…"
14 hours ago
complience replied to The Ning Team's discussion Acquisition Update
14 hours ago
Suki Winthrop replied to The Ning Team's discussion Acquisition Update
"Yet more of the same shabby treatment I guess."
14 hours ago
⚡JFarrow⌁ replied to The Ning Team's discussion Acquisition Update
"Where is tomorrow's announcement?"
17 hours ago
Kos replied to The Ning Team's discussion Acquisition Update
"Nice job Janice!  Yes, I think it's important to contain emails somewhere off site.....for just tho…"
17 hours ago
Janice D Carter replied to The Ning Team's discussion Acquisition Update
"Part of my terms is that it is ok to email them and to be fair they ALL have access to one of my em…"
17 hours ago
Shadow replied to The Ning Team's discussion Acquisition Update
"Curious so others can know.. as if our site is down and cant reach members we have to lump it .. sh…"
17 hours ago
Janice D Carter replied to The Ning Team's discussion Acquisition Update
"Kos,
I no longer export but what I have done is go to using Mailchimp.  I keep an ongoing list of m…"
18 hours ago
Shadow replied to The Ning Team's discussion Acquisition Update
"ours will be 1200.. 600 is fair.. if they go 700 for pro would be also considered fair.. 1200 no..…"
18 hours ago
Shadow replied to The Ning Team's discussion Acquisition Update
"I have always watched for this with my site from seeing what happened to Humanity healng site.. FBI…"
18 hours ago
Garfield Archivist replied to The Ning Team's discussion Acquisition Update
"You're welcome. Thanks for taking the time to say so."
19 hours ago
RJ Blanco replied to The Ning Team's discussion Acquisition Update
"YEP"
19 hours ago
RJ Blanco replied to The Ning Team's discussion Acquisition Update
"ANY UPDATES???"
19 hours ago
George Swann replied to PeruCool's discussion Alternatives to Ning social network
"Ignoring the posts from a few here who have agendas seriously bent on discouragement and discrediti…"
19 hours ago
Hugh replied to The Ning Team's discussion Acquisition Update
"I guess with Ning 'tomorrow' never comes."
23 hours ago
More…