我有Joomla v3.x.x模板覆盖,它使用一些类别过滤器创建同位素布局。
我遇到的问题是,如果将&符号(&)放入类别的标题中,则不会显示该特定的类别过滤器。
是一种逃避或允许&符号(&)显示并且不会破坏该特定类别的过滤器的方法吗?
代码:
<?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;
这是从类别标题创建过滤器的特定行:
<li class="btn btn-primary"><a href="#" data-option-value=".<?php echo $data_option; ?>"><?php echo $this->escape($child->title); ?></a></li>
答案 0 :(得分:0)
问题很可能与过滤器选择的渲染有关。尝试更改以下行:
<?php $data_name = $this->escape($child->title); ?>
为:
<?php $data_name = htmlspecialchars($child->title); ?>
看看是否能解决问题。