Joomla 3 - category violation if category header contains ampersand &

I have a Joomla v3.xx template override that creates an isotopic layout with some category filters.

The problem is that if an ampersand (&) is placed in a category heading, that category-specific filter will not appear.

Is there a way to avoid or allow the ampersand (&) to show and not break the filter for that particular category?

code:

<?php
defined('_JEXEC') or die;

JHtml::_('bootstrap.tooltip');

if (count($this->children[$this->category->id]) > 0 && $this->maxLevel != 0) : ?>

    <?php foreach ($this->children[$this->category->id] as $id => $child) : ?>
        <?php if ($this->params->get('show_empty_categories') || $child->numitems || count($child->getChildren())) : ?>

            <?php $data_name = $this->escape($child->title); ?>
            <?php $data_option = str_replace(' ', '', $data_name); ?>

            <li class="btn btn-primary"><a href="#" data-option-value=".<?php echo $data_option; ?>"><?php echo $this->escape($child->title); ?></a></li>

            <?php if (count($child->getChildren()) > 0) : ?>

                <?php
                $this->children[$child->id] = $child->getChildren();
                $this->category = $child;
                $this->maxLevel--;
                if ($this->maxLevel != 0) :
                    echo $this->loadTemplate('children');
                endif;
                $this->category = $child->getParent();
                $this->maxLevel++;
                ?>

            <?php endif; ?>

        <?php endif; ?>
    <?php endforeach; ?>

<?php endif;

      

This is a specific string that creates filters from category names:

<li class="btn btn-primary"><a href="#" data-option-value=".<?php echo $data_option; ?>"><?php echo $this->escape($child->title); ?></a></li>

      

+3


source to share


1 answer


The problem is most likely related to the rendering of the filter selection. Try changing the following line:

<?php $data_name = $this->escape($child->title); ?>

      

in



<?php $data_name = htmlspecialchars($child->title); ?>

      

And see if that fixes the problem.

0


source







All Articles