CMS BUILDER AND LISTS OF RANKINGS , TOP 5, TOP 10, TOP 100, ETC...

9 posts by 2 authors in: Forums > CMS Builder
Last Post: May 16, 2013   (RSS)

By carlos.pinedo - May 12, 2013 - edited: May 12, 2013

HI, 

I´m using the CMS Builder to build the cms of an sports web site. As you can imagine there are a lot of rankings in this websites; top 5 players, top 10 teams, etc.

Right now, in order to edit these rankings i'm using lists of numbers. The editor has to choose a number from a list ,and assign it to a certain item. 

For instance:

  1. team star.
  2. team sun.
  3. team moon.

I thought that i could use the option "get options from the database" to make this process easier and faster for the editor,

      Making a list ,

      getting options from the database,

      using the "dragSortOrder" field .

But, instead of getting: 

  1. team star.
  2. team sun.
  3. team moon.

I got:

      30. team star.
      20. team sun.
      10. team moon.

A zero is added and the order is inverted. I used the "num" field but, it didn't work either, because the number from the "num" field it´s not related to the position of the record.

So, my Question is: Is there an automatic way to make rankings, based on the positions of the records?

By carlos.pinedo - May 13, 2013 - edited: May 13, 2013

Hi Greg, 

I made a one minute video, I recorded the screen and added captions explaining my question better.

Please watch it, 

http://www.fecofutsalon.com/ranking.php

Thanks!

Carlos

By gregThomas - May 14, 2013

Hi Carlos,

Sorry for the delay in reply.

The video you posted was great! I've got a good understanding of what you're trying to achieve.

Are there likely to be a lot of teams that need sorting for each section? I'm wondering if you need the ranking field at all. You could remove the ranking field, then get the site admin to drag the teams into the correct ranking order, and then display the ranking number on the front end of the site for the users. If you use a getRecords function to retrieve the teams, it will automatically sort the teams into the list order. Then you could use either a counter to rank the teams something like this:

<?php $counter = 0; ?>
<?php  foreach($teams as $team): ?>
  <?php echo $counter++; ?>. <?php echo $team['team']; ?><br>
<?php endforeach; ?>

or you could display the results in an ordered list (http://www.w3schools.com/html/tryit.asp?filename=tryhtml_lists).

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By carlos.pinedo - May 14, 2013 - edited: May 14, 2013

Hi Greg,

There are not that many teams that need sorting, but there are a lot of players that do need it; the counter works great (Thanks a lot!), but the ranking field would be nicer for the site admin, because he would be able to see the numbers while he´s draging the players. Is possible to achieve the ranking field ?

Carlos Pinedo

By gregThomas - May 15, 2013

Hi Carlos,

Unfortunately there isn't an easy way this can be done in CMS Builder by default. But we could develop a plugin for you that could do this, if you send an e-mail to consulting@interactivetools.com we can give you an estimate of the cost. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By carlos.pinedo - May 16, 2013 - edited: May 16, 2013

Hi Greg

I´ll send an e-mail to consulting@interactivetools.com, i´m interested in buying the plugin. Mean While I´m going to keep using the counter, as I told you, it works great.  I have another question regarding to this:

Is it possible to turn the numbers from the counter in to letters, so, 1,2,3,4,5 will become a,b,c,d,e?

Thanks for everything

Carlos

By gregThomas - May 16, 2013

Hi Carlos,

I found a function that will convert numbers to their alphanumeric equivalents here: http://studiokoi.com/blog/article/converting_numbers_to_letters_quickly_in_php

Here is the code I used previously using this function:

  function num_to_letter($num, $uppercase = FALSE){
    $num -= 1;
    
    $letter =   chr(($num % 26) + 97);
    $letter .=  (floor($num/26) > 0) ? str_repeat($letter, floor($num/26)) : '';
    return    ($uppercase ? strtoupper($letter) : $letter); 
  }

?>
  <?php $counter = 1; ?>
  <?php  foreach($teams as $team): ?>
    <?php echo num_to_letter($counter++); ?>. <?php echo $team['team']; ?><br>
  <?php endforeach; ?>

Let me know if you have any questions. 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi Greg, it works really well. 

Thanks Again!

Carlos Pinedo