gpt4 book ai didi

php - Joomla 3 - 如果类别标题包含&符号,则类别链接中断&

转载 作者:搜寻专家 更新时间:2023-10-31 22:02:10 24 4
gpt4 key购买 nike

我有 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>

最佳答案

该问题很可能与过滤器选择的呈现有关。尝试更改以下行:

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

到:

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

看看是否能解决问题。

关于php - Joomla 3 - 如果类别标题包含&符号,则类别链接中断&,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27124132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com