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

Giovanni Cappai replied to Giovanni Cappai's discussion HTML under header not working :/
"Hi Kyryl, thanks for your reply. On firefox it works, on chrome still doesn't."
34 minutes ago
Philip Voice replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"I opened a private chat with one of my members yesterday. Nothing was typed in the chat by either o…"
54 minutes ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Paid Access demo version
"Hi there!
Thanks for your feedback it is highly appreciated.
I have updated already existing sugges…"
1 hour ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Hi there!
Thanks for useful suggestions! Some of them were completely new and some I have already p…"
1 hour ago
Philip Voice replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"If anyone is interested if you want to do an off-grid search of your network (or any site) it's eas…"
1 hour ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Hi there,
Unfortunately after the implementation of new chat, we are experiencing the high servers…"
1 hour ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Hi there!
I'm glad that I have been able to help :-) 
But I have posted your suggestion anyway to m…"
2 hours ago
Kyryl_Ning_Support replied to Giovanni Cappai's discussion HTML under header not working :/
"Hi Giovanni,
I have just checked and it seems to be working fine. As far as I can see you have adde…"
2 hours ago
Kyryl_Ning_Support replied to Fabricio Giugni's discussion Powered by Ning How to get it out?
"Hi there!
Unfortunately, at this point, it's forbidden to "Powered by Ning" logo from the footer of…"
2 hours ago
Brandyn Shepherd replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Please add...- Option to see who is online at first glance.- Add text to chat bar that lets users k…"
3 hours ago
J.Ayvar replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"Yes, the advanced search is very important is a social community. 
When they said they were working…"
4 hours ago
Paul Corona replied to Dr. Krishna Kumari Challa's discussion I am unable to find discussions on my network when I search. Any solutions?
"2 points: 
1) it works


2) if it works does it matter if its Google if it's from Mars?"
6 hours ago
Thisisbully replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"I removed it it has a lot of bugs that needs to be fixed"
6 hours ago
Kos replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Here I thought it was just me.  Yeah, it's been down since late this afternoon............."
6 hours ago
Dr. Krishna Kumari Challa replied to Dr. Krishna Kumari Challa's discussion I am unable to find discussions on my network when I search. Any solutions?
"Thanks but this looks like google search."
6 hours ago
J.Ayvar replied to Kyryl_Ning_Support's discussion Paid Access demo version
"I totally agree with with Jords and Alex ! 
Our company has managed 15 Ning projects on the last fo…"
10 hours ago
Ceddy J replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"So it just dawned on me that you're a CSS Maestro! Impressed by your chops."
15 hours ago
Kyryl_Ning_Support replied to Kyryl_Ning_Support's discussion Chat Feature Update on Ning 3.0 is ready!
"Hi there!
Here is what I have been able to do. all the following code sould be put in custom CSS fi…"
16 hours ago
Ning via Facebook

#Ning #search #news The long-awaited Search Option on Ning 3.0 is here! We are happy to…

Kos replied to Kyryl_Ning_Support's discussion The long-awaited Search Option is now at your fingertips!
"We've been waiting for years................Thank you (new) Ning!  Keep those improvements coming. "
17 hours ago
More…