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

Kos replied to FedMedic's discussion Sliders anyone?
"POWR is cool, even the free. Diff sizes, diff. fonts, diff. displays and location...........etc."
31 minutes ago
Fire-Tech replied to FedMedic's discussion Sliders anyone?
"Yeah, I know all too well my friend :)"
2 hours ago
FedMedic replied to FedMedic's discussion Sliders anyone?
"I just got back on here to read the suggestions. I'll let you know when I try Fire-Tech's suggestio…"
3 hours ago
FedMedic replied to FedMedic's discussion Sliders anyone?
"Hi Fire-Tech, I removed the code. Sorry it took me so long to get back here. Being in the fire busi…"
3 hours ago
Luke Jones replied to Luke Jones's discussion My member's can't use the Emoji's when their using their phones
"Ah right,will check then,thanks Kos :)"
3 hours ago
Kos replied to Luke Jones's discussion My member's can't use the Emoji's when their using their phones
"I would check w/them, then a/b mobile."
3 hours ago
Luke Jones replied to Luke Jones's discussion My member's can't use the Emoji's when their using their phones
"Thanks Kos :) I have comet chat, but I mean't when people are writing a private message and on comm…"
3 hours ago
Kos replied to Luke Jones's discussion My member's can't use the Emoji's when their using their phones
"I use "Cometchat" and while members have to manually type it in, they work.  idk a/b Chatabox.  Sor…"
4 hours ago
Rowald replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"We can not judge something is good from one perspective."
12 hours ago
Writer Chick {Diane} replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"I still like 3 better than anything I've seen out there. Maybe it's not right for some of you, but…"
15 hours ago
Kos replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"LOL!"
16 hours ago
Fire-Tech replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"New Developer Mode will like rock too...Like, aha :p
... had to...(old timer feeling old)..."
17 hours ago
Sam O'Prey, Pedro de H.Abuhassan, Execed and 1 more joined Ning Creators Network
19 hours ago
Mary Jane Peterson replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"I wish they do some thing  "
23 hours ago
Mary Jane Peterson replied to Mary Jane Peterson's discussion Power by ning
"thank you 

ning is so unfair on their customers "
23 hours ago
Strumelia replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"I don't feel you can call something great based on what it 'might' be, some day...or not.  It certa…"
yesterday
Strumelia replied to Mary Jane Peterson's discussion Power by ning
"Or... buy somebody's 2.0 network and make it into what you want. You can still freely remove the Po…"
yesterday
Kos replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"They're completely different from who they were.  3.0 is still a great platform though; IF Ning com…"
yesterday
Rowald replied to Mary Jane Peterson's discussion Power by ning
"There is a way but it's against Ning's new (ridiculous) TOS."
yesterday
Rowald replied to Luke Jones's discussion Ning have finally got back to me!!! Lets throw a party :P
"Even if they release all features I could think of I wonder if Ning/Glam could ever win trust back.…"
yesterday
More…