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

Saurabh replied to Saurabh's discussion How to add content in status update page?
"let me explain again...
Today a new feature activity feeds was launched... so now you can update st…"
11 minutes ago
Anam replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"I don't know if Ning has moderators or not Strumelia to be honest, as i m still only getting the ha…"
25 minutes ago
Kos replied to Saurabh's discussion How to add content in status update page?
"ok now they both show a sidebar.  To add more content, just add another content box in sites & page…"
27 minutes ago
soaringeagle replied to Fire-Tech's discussion 3.0 Tip: Status Update Box Tweaks
"as soon as it was released i was working on my own lil tweak"
28 minutes ago
Saurabh replied to Saurabh's discussion How to add content in status update page?
"both have the code"
32 minutes ago
Strumelia replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"As it stands members could join and crap all over your site in Comment Walls on Groups and you woul…"
35 minutes ago
Kos replied to Saurabh's discussion How to add content in status update page?
"Well there's the "members" page (where all of your members show) and the "my page" which is the ind…"
44 minutes ago
Saurabh replied to Saurabh's discussion How to add content in status update page?
"I already have in members pages http://engineeringwall.com/members"
51 minutes ago
Anam replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"So, no-one else has a problem with Comments on Group Comment Walls not showing up in the new Latest…"
58 minutes ago
C.Brickhouse replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"so if I have hosting already with go daddy how would i go about getting the site I want?  I saw lay…"
1 hour ago
John Bizley replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"hmm, I just tried it again on mine and it changed ok. This was in FireFox and ie. Will investigate…"
1 hour ago
Kos replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"I tried that"
2 hours ago
Kos replied to Saurabh's discussion How to add content in status update page?
"Saurabh you have to change the layout for member pages in sites & pages - then add content in the s…"
2 hours ago
John Bizley replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"Kos to change it you just place your cursor at the start and type what you need, the 'What are you…"
2 hours ago
Writer Chick {Diane} replied to Anthony "DarkGemineye" Johnson's discussion PlayStation Haven is back. Let me know what you think.
"Gotta say, your site looks amazing.  It's great to hear (and see) a success story! "
3 hours ago
steve replied to Stig Karlsen's discussion When will Ning 3.0 be compatible with tablets - iPad and iPhones?
"its truly worrying this bit of news and i dont get it, why would you make a new modern platform tha…"
3 hours ago
ceri shaw replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"Still totally non functional on my site ( http://americymru.net ).  The More button doesnt work and…"
5 hours ago
Kos replied to Ning's discussion Introducing Activity Feed Improvements, Including Member Status Updates
"Unable to change status prompt from "what are you up to?" in Firefox.  Did a hard refresh.  Have no…"
5 hours ago
Denis replied to Stig Karlsen's discussion When will Ning 3.0 be compatible with tablets - iPad and iPhones?
"Really? Then I think I got the meaning of "responsive design" wrong. Ning 3.0 has been touted since…"
6 hours ago
Anam replied to Fire-Tech's discussion 3.0 Tip: Status Update Box Tweaks
"Thank you FireTech. That looks and works really groovy :)"
7 hours ago
More…