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

Fire-Tech replied to Tyler Durbin's discussion 2.0 Sliders instructions?
"Yup. I have had / made a few in the past. They are always a pain... but their new one is painless.…"
9 hours ago
Tyler Durbin replied to Tyler Durbin's discussion 2.0 Sliders instructions?
"Thanks Fire, I see they are going to come out with a 2.0 version."
9 hours ago
Tyler Durbin replied to Tyler Durbin's discussion 2.0 Sliders instructions?
"Thanks Kos, I will look some more. "
9 hours ago
Tyler Durbin replied to Katie McKay's discussion I love my new slider!
"Definitely let us know!"
9 hours ago
Strumelia replied to Strumelia's discussion Particular issue with Ning Archiver: archiver can't access its own .json files?
"I will try that next time- have to wait another 24 hrs now...   thank you!"
9 hours ago
JFarrow replied to Strumelia's discussion Particular issue with Ning Archiver: archiver can't access its own .json files?
"i believe i set it to allow read/write permissions as it was only set to read"
10 hours ago
Strumelia replied to Strumelia's discussion Particular issue with Ning Archiver: archiver can't access its own .json files?
"JF-  thank you , I will try this next time then!   Can you please tell me what permissions/properti…"
10 hours ago
JFarrow replied to Strumelia's discussion Particular issue with Ning Archiver: archiver can't access its own .json files?
"I recieved that same error the other day.  I then logged out of archiver, reset the permissions/pro…"
10 hours ago
Jeffrey Haskins replied to Karl Harrison's discussion Deleting Data
"The question really is...is keeping their information worth all the issues and battles?"
10 hours ago
Fire-Tech replied to Fire-Tech's discussion 3.0 Tip: Message Notification Background
"Thanks J ;)"
11 hours ago
JFarrow replied to Fire-Tech's discussion 3.0 Tip: Message Notification Background
"nice tip brother"
11 hours ago
Fire-Tech replied to Tyler Durbin's discussion 2.0 Sliders instructions?
"A bunch of us have been using the new one from Jen & TJ. I love it! Here's a discussion about it."
16 hours ago
Kos replied to Karl Harrison's discussion Deleting Data
"Checkout your Terms of Service at the bottom of your site. 

the Network Creator of this Network co…"
19 hours ago
George H. Compton IV replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"lol damn cellphones lol Scott I think Garfield said it best when he said "get the impact of this co…"
19 hours ago
Scott Bishop replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Sorry bro, no go. Both Chrome & IE. Cleared cache, cookies and browser history. "
yesterday
Kos replied to Tyler Durbin's discussion 2.0 Sliders instructions?
"Hey Tyler I used to use a slider designed by SweetPotato.  Maybe checkout his page and go through h…"
yesterday
George H. Compton IV replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Scott, I added a @media query that targets the Galaxy 111. Can you go have another look? :-)"
yesterday
Scott Bishop replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Using either Chrome for IE on my GIII your http://beachcatsaustralia.ning.com site doesn't go respo…"
yesterday
George H. Compton IV replied to George H. Compton IV's discussion (TIP) Ning 2.0 responsive fullwidth network at any screen resolution. :O Cellphones to TV's ;)
"Scott can you explain to me little more on what problems you are having with the Galaxy III, is it…"
yesterday
George H. Compton IV replied to Scott Bishop's discussion 301 Redirect from N2 to Offsite
"Hey Scott even better use this, I just wrote it :-) Redirect any individual page from your custom…"
yesterday
More…