Sort tags alphabetically

Permalink Browser Info Environment
Perhaps this question has been posted and answered a zillion of times, but my research did not give me any result. Is it possible to sort the tags alphabetically? What I see in the blocked installed deals with «pages».

Type: Discussion
Status: New
GuyVerville
View Replies: View Best Answer
GuyVerville replied on at Permalink Reply
GuyVerville
I have found a crude way to do this. I am not very familiar yet with either php or Concrete5 API. Instead of concatenating the output, I sort the elements set in two arrays using the function array_multisort.

<?php
   $tagsB = array();
$tagsC = array();
   for ($i = 0; $i < $ttags->count(); $i++) {
      $akct = $tags[$i];
      $tagsB[] = nettoyerB($akct->getSelectAttributeOptionValue());      
      $tagsC[] = $akct->getSelectAttributeOptionUsageCount();      
   }
   ?>
   <?php
   array_multisort($tagsB, $tagsC);
   for ($i = 0; $i < $ttags->count(); $i++) {
      //$qs = $akc->field('atSelectOptionID') . '[]=' . $akct->getSelectAttributeOptionID();
      echo '<div><a href="'.BASE_URL.$search.str_replace(' ','_',$tagsB[$i]).'/">'.$tagsB[$i].' ('.$tagsC[$i].')</a></div>';
   }
ministrycrm replied on at Permalink Best Answer Reply
ministrycrm
This code works with 5.6

Here is the whole view:
<?php  defined('C5_EXECUTE') or die("Access Denied.");  ?>
<div class="ccm-tags-display">
<?php  if(strlen($title)) {
   ?><h4><?php  echo $title ?></h4><?php
}
if($options instanceof SelectAttributeTypeOptionList && $options->count() > 0) {
foreach($options as $opt){
    $data[] = $opt;
}
function cmp($a, $b) {
    return $a->value - $b->value;
}
usort($data, 'cmp');
$options = $data;
natsort($options);
GuyVerville replied on at Permalink Reply
GuyVerville
That is very kind of you. Thank you!
RadiantWeb replied on at Permalink Reply
RadiantWeb
agreed. kudos!

ChadStrat

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.