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 gregThomas - May 13, 2013

Hi Carlos,

I think I'm going to need  a bit more information before I can help. Which section is the "get list options from the database" field using? Is this field in the sports team section? Also, could you attach the code that you're using to display the sports teams on the page?

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

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