3
打破类别链接我有Joomla v3.x.x模板覆盖,创建一个同位素布局与一些类别的过滤器。Joomla 3 - 类别链接如果类别标题包含与&
我遇到的问题是,如果将&符号(&)放入类别的标题中,该特定的类别过滤器将不会显示。
是一种逃避或允许&符号(&)显示并且不破坏该特定类别的过滤器的方法吗?
代码:
<?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>
类别名称在进入数据库之前应进行消毒。您是否检查了类别获取条目,以查看数据库中的&是如何保存的。尝试通过htmlspecialchars_decode()运行之后比较类别名称,或者通过htmlspecialchars()运行您正在比较的类别名称。 – 2014-11-25 16:10:17
谢谢布赖恩 - 有什么办法可以在上面的代码中做到这一点,当拉标题? – user3544484 2014-11-25 18:06:05