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

⚡JFarrow⌁ replied to Alex Seymour's discussion iframe question on test network
"my pleasure bud.. let me know how it turns out... "
5 hours ago
Alex Seymour replied to Alex Seymour's discussion iframe question on test network
"Thanks JFarrow. I saw that code. However I need to pass a variable to the iframe like. <script lan…"
5 hours ago
Alex Seymour replied to Alex Seymour's discussion iframe question on test network
"ah ok. That makes sense.I can't just put it on the live network as it is a cart for shopping and wo…"
6 hours ago
⚡JFarrow⌁ replied to Alex Seymour's discussion iframe question on test network
"Kos is right.  That script you are using must have another component which doesn't exist on your te…"
6 hours ago
Kos replied to Alex Seymour's discussion iframe question on test network
"It could just be that iframes (among other things) are not supported on test sites.  Why is that a…"
6 hours ago
Sanjay Barmashakha, Katy Blagg and Akhilesh Kumar joined Ning Creators Network
yesterday
Kristin replied to Jeffrey Haskins's discussion It really does look like NING is dead, or nearly there
"Really frustrating."
Sunday
⚡JFarrow⌁ replied to Mia's discussion Access word docs from archive?
"This is what the page linked to by Eric used to say:
ARCHIVE YOUR MEDIA FILES



After you have ins…"
Sunday
⚡JFarrow⌁ replied to Jeffrey Haskins's discussion It really does look like NING is dead, or nearly there
"Suicide"
Saturday
Margaret Ditty replied to Crystal's discussion Welcome to Creators 3.0!
"Is there such a thing as an iPhone app with Ning similar to what Facebook has?"
Saturday
George H. Compton IV replied to George H. Compton IV's discussion MY Firefox Restore 2017 v11 free Download
"I purchased a new compiler today so I had to update this app.  My Firefox Restore Version 11.1"
Friday
Alex Pidgley is now a member of Ning Creators Network
Friday
Jon Roberts replied to Jeffrey Haskins's discussion It really does look like NING is dead, or nearly there
"I'm right there with you. We have subscribed since 2012. A refund would be justice served, however…"
Friday
Ambroise replied to Ambroise's discussion [Graph API error] Facebook alert
"Here is the rest of the conversation (see below)Ning responses are fast but are not effective. Appa…"
Jun 22
Kos replied to Ambroise's discussion [Graph API error] Facebook alert
"Well I'm glad you posted it here at Creators, in case others experience the same problem.  When it…"
Jun 22
Ambroise replied to Ambroise's discussion [Graph API error] Facebook alert
"Thank you for your answer Kos I received a fairly detailed response from Ning assistance service, w…"
Jun 22
Ambroise replied to Ambroise's discussion [Graph API error] Facebook alert
"Here following the conversation I had with Ning Helpdesk :
23 juin 2016 at 2:13
Réponse (Ioana)
Hey…"
Jun 22
JASON M HARRIS replied to Speed Racer's discussion Develop an iPhone or Android App?
"I'm new to NING... They are a weird company... Lots of common sense things, to do better business,…"
Jun 22
Kos replied to Ambroise's discussion [Graph API error] Facebook alert
"I haven't received any notifications but maybe it's to come (?).  Please let us know how Ning respo…"
Jun 22
Shelli Poole replied to Shelli Poole's discussion Is there a back door to managing blogs/discussions in bulk?
"Found a way to do 10 at a time on the blogs..."
Jun 21
More…