A
A
Apostol632021-10-14 12:14:42
Joomla
Apostol63, 2021-10-14 12:14:42

How to sort categories in joomla?

Good day to all.

I got my hands on a site on joomla. The client had a broken display of categories on the page. I fixed the output itself, but I can’t fix the sorting
6167f3320dc0d955516926.png

(the image for the convenience of orienting by line numbers, I wrote this code below the line)

on lines 29 and 31 there are inputs that have an onchange method, which, logically, should change the $grouped variable ( line 42) and $list( lines 43 and 123).
By default, $grouped is equal to 1, which means grouping by regions.
If you click on the input "in alphabetical order", then somewhere the value of the $grouped and $list variables should change.
The problem is, I don't know where.

If you click on the input "in alphabetical order", then an error is displayed
Notice: Undefined variable: select in C:\OpenServer\domains\creditrisl\templates\art\html\mod_articles_category\country.php on line

31 $select variable is unknown. In this php file, it was not originally set anywhere. Apparently, it should be set in the same place as $grouperd and $list

Who knows what can be done here?

Thank you very much in advance

<?php
/**
 * @package     Joomla.Site
 * @subpackage  mod_articles_category
 *
 * @copyright   Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

$doc = JFactory::getDocument();
$lang = $doc->getlanguage();
?>
<?php if($lang == "en-gb") : ?>
    <div class="sorting">
        <p>Sort by </p>
        <form method="post" class="sort-form">
            <input class="hide" id="cat" name="selector" type="radio" value="category" onchange="this.form.submit()" <?php if(!isset($_POST['selector'])){echo "checked";}else{ echo $select['category']; }  ?>>
            <label class="cityclose " for="cat">regions</label>
            <input class="hide" id="tit" name="selector" type="radio" value="title" onchange="this.form.submit()" <?= $select['title']; ?>>
            <label class="cityclose " for="tit">alphabet</label>
        </form>
    </div>
<?php else: ?>
    <div class="sorting">
        <p>Сортировка по </p>
        <form method="post" class="sort-form">
            <input class="hide" id="cat" name="selector" type="radio" value="category" onchange="this.form.submit()" <?php if(!isset($_POST['selector'])){echo "checked";}else{ echo $select['category']; }  ?>>
            <label class="cityclose " for="cat">регионам</label>
            <input class="hide" id="tit" name="selector" type="radio" value="title" onchange="this.form.submit()" <?= $select['title']; ?>>
            <label class="cityclose " for="tit">алфавиту</label>
        </form>
    </div>
<?php endif; ?>


<div>

<ul class="category-module<?php echo $moduleclass_sfx; ?>">

  <?php if ($grouped) : ?>
    <?php foreach ($list as $group_name => $group) : ?>

            <!--<?php if(!empty($group->link)) : ?>
            <div class="mod-articles-category-group"><a href="<?= $group['link']; ?>"><?php echo $group_name; ?></a></div>
            <?php else: ?>
            <div class="mod-articles-category-group"><?php echo $group_name; ?></div>
            <?php endif; ?>-->
            <div class="mod-articles-category-group"><?php echo $group_name; ?></div>
      <ul class="continent">
        <?php foreach ($group as $item) : ?>
                    <?php
                        $image = json_decode($item->images, true);
                    ?>
          <li>
            <?php if ($params->get('link_titles') == 1) : ?>

                            <?php if($image['image_intro']) : ?>
                                <img src= "/<?php echo $image['image_intro'] ?>" alt="<?php echo $item->title; ?>" />
                            <?php endif; ?>
              <a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
                <?php echo $item->title; ?>
              </a>
            <?php else : ?>
              <?php echo $item->title; ?>
            <?php endif; ?>

            <?php if ($item->displayHits) : ?>
              <span class="mod-articles-category-hits">
                (<?php echo $item->displayHits; ?>)
              </span>
            <?php endif; ?>

            <?php if ($params->get('show_author')) : ?>
              <span class="mod-articles-category-writtenby">
                <?php echo $item->displayAuthorName; ?>
              </span>
            <?php endif; ?>

            <?php if ($item->displayCategoryTitle) : ?>
              <span class="mod-articles-category-category">
                (<?php echo $item->displayCategoryTitle; ?>)
              </span>
            <?php endif; ?>

            <?php if ($item->displayDate) : ?>
              <span class="mod-articles-category-date"><?php echo $item->displayDate; ?></span>
            <?php endif; ?>

            <?php if ($params->get('show_introtext')) : ?>
              <p class="mod-articles-category-introtext">
                <?php echo $item->displayIntrotext; ?>
              </p>
            <?php endif; ?>

            <?php if ($params->get('show_readmore')) : ?>
              <p class="mod-articles-category-readmore">
                <a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
                  <?php if ($item->params->get('access-view') == false) : ?>
                    <?php echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE'); ?>
                  <?php elseif ($readmore = $item->alternative_readmore) : ?>
                    <?php echo $readmore; ?>
                    <?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
                      <?php if ($params->get('show_readmore_title', 0) != 0) : ?>
                        <?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
                      <?php endif; ?>
                  <?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
                    <?php echo JText::sprintf('MOD_ARTICLES_CATEGORY_READ_MORE_TITLE'); ?>
                  <?php else : ?>
                    <?php echo JText::_('MOD_ARTICLES_CATEGORY_READ_MORE'); ?>
                    <?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
                  <?php endif; ?>
                </a>
              </p>
            <?php endif; ?>
          </li>
        <?php endforeach; ?>
      </ul>

    <?php endforeach; ?>
  <?php else : ?>
    <?php foreach ($list as $item) : ?>
            <?php
                $image = json_decode($item->images, true);
            ?>
      <li>
        <?php if ($params->get('link_titles') == 1) : ?>
                    <?php if($image['image_intro']) : ?>
                        <img src= "/<?php echo $image['image_intro'] ?>" alt="<?php echo $item->title; ?>" />
                    <?php endif; ?>
          <a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>"><?php echo $item->title; ?></a>
        <?php else : ?>
          <?php echo $item->title; ?>
        <?php endif; ?>

        <?php if ($item->displayHits) : ?>
          <span class="mod-articles-category-hits">
            (<?php echo $item->displayHits; ?>)
          </span>
        <?php endif; ?>

        <?php if ($params->get('show_author')) : ?>
          <span class="mod-articles-category-writtenby">
            <?php echo $item->displayAuthorName; ?>
          </span>
        <?php endif; ?>

        <?php if ($item->displayCategoryTitle) : ?>
          <span class="mod-articles-category-category">
            (<?php echo $item->displayCategoryTitle; ?>)
          </span>
        <?php endif; ?>

        <?php if ($item->displayDate) : ?>
          <span class="mod-articles-category-date">
            <?php echo $item->displayDate; ?>
          </span>
        <?php endif; ?>

        <?php if ($params->get('show_introtext')) : ?>
          <p class="mod-articles-category-introtext">
            <?php echo $item->displayIntrotext; ?>
          </p>
        <?php endif; ?>

        <?php if ($params->get('show_readmore')) : ?>
          <p class="mod-articles-category-readmore">
            <a class="mod-articles-category-title <?php echo $item->active; ?>" href="<?php echo $item->link; ?>">
              <?php if ($item->params->get('access-view') == false) : ?>
                <?php echo JText::_('MOD_ARTICLES_CATEGORY_REGISTER_TO_READ_MORE'); ?>
              <?php elseif ($readmore = $item->alternative_readmore) : ?>
                <?php echo $readmore; ?>
                <?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
              <?php elseif ($params->get('show_readmore_title', 0) == 0) : ?>
                <?php echo JText::sprintf('MOD_ARTICLES_CATEGORY_READ_MORE_TITLE'); ?>
              <?php else : ?>
                <?php echo JText::_('MOD_ARTICLES_CATEGORY_READ_MORE'); ?>
                <?php echo JHtml::_('string.truncate', $item->title, $params->get('readmore_limit')); ?>
              <?php endif; ?>
            </a>
          </p>
        <?php endif; ?>
      </li>
    <?php endforeach; ?>
  <?php endif; ?>
</ul>
</div>

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