Joomla v3在一条语句中包含多个PHP IF'


Joomla v3 multiple PHP IF's in one statement

在Joomla v3中,我想做以下事情:

'countModules'使用以下命令来指定模块,以查看模块是否被分配:

<?php if ($this->countModules('right')) : ?>

但是我也只想在文章页面上显示模块位置,而不是使用下面的分类博客页面:

<?php if( JRequest::getVar( 'view' ) == 'article' ): ?>

我如何将上述两个IF放入下面的一个语句中,以便模块位置不显示&div仅在类别博客页面上被删除(但在文章页面上显示):

<section class="sidebar right-sidebar">
   <jdoc:include type="modules" name="right" style="standard" />
</section>

这是你要找的吗?

<?php
   $jinput = JFactory::getApplication()->input;
   $view = $jinput->get('view');
   if($view == 'article' && $this->countModules('right')) {
   ?>
      <section class="sidebar right-sidebar">
          <jdoc:include type="modules" name="right" style="standard" />
      </section>
   <?php
   }
?>

还删除了您正在使用的旧的已弃用的JRequest,而使用JApplication