B
B
Boris Belov2016-09-08 15:58:56
Joomla
Boris Belov, 2016-09-08 15:58:56

How to list categories alphabetically?

Hello, I have this code

<?php foreach ($this->intro_items as &$item){
      $counter_material +=1;
      $its_a_end = 0;
      if($counter_material==1){
        $counter_column +=1;
        echo '<div class="columns column-'.$counter_column.'">';
        if($first_letter==substr($item->title,0,1)){
          echo '<div class="arhiv_content obchi">';
        }
      }
        if($first_letter!=substr($item->title,0,1)){
          $first_letter = substr($item->title,0,1);
//					echo '-||'.$counter_material.'||-';
          if($counter_material>1) echo '</div>';
          echo '<h3 class="arhiv_letter">'.$first_letter.'</h3>';
          echo '<div class="arhiv_content neobchi">';
        }

      ?>
        <a href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($item->slug, $item->catid)); ?>">
          <span>
            <?php echo $item->title; ?>
          </span>
        </a>
      <?php 			
        //echo $counter_material.' >= '.$num_materail_in_column.' || '.$counter_material.' >= '.$num_links."\n";
        //echo $counter_material.'>='.count($this->intro_items)."\n";
        if($counter_material >= $num_materail_in_column||$counter_material>=count($this->intro_items)){
          $counter_material = 0;
          $its_a_end = 1;
            echo '</div>';
          echo '</div>';
        }
      };
      
      if(!$its_a_end){
          echo '</div>';
        echo '</div>';
      }

      ?>

And this is how it is displayed.
7c1bd43be4624500913ff0f7f6b343f7.png
That is, for some reason, category A and category N are not displayed correctly. And instead of displaying all categories from A, it displays, as you can see, for some reason one category from A, then two from N.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question