如何仅在页面不是文章时显示元素?

  • 本文关键字:文章 显示 元素 何仅 joomla
  • 更新时间 :
  • 英文 :


我在mod_breadcrumb/default.php的重写中有一个代码片段,以便在视图是文章时不显示Breadcrumb的最后一个li元素。

代码是:

<?php if( JRequest::getVar( 'view' ) != 'article' ): ?>
<li itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem" class="breadcrumb-item active"><?php echo $breadcrumbItem; ?>
<meta itemprop="position" content="<?php echo $key + 1; ?>">
</li>
<?php endif; ?>

现在在Joomla 4中,JRequest正在创建错误:

类"JRequest"没有找到

,我们必须使用另一个代码。任何帮助吗?由于

JRequest在Joomla 3中也被弃用了,而支持JInput

$value = JFactory::getApplication()->input->get('view');

input->get支持三个参数,只需要第一个;完整语法为:

input->get('name','default','filter').

可行的解决方案是:

<?php if( $app->getInput()->get('view') != 'article' ): ?>

最新更新