Joomla v3多个PHP IF在一个声明中

时间:2014-05-20 10:49:20

标签: php if-statement joomla joomla3.0

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

'countModules'具有以下内容的模块,以查看是否已分配模块:

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

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

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

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

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

1 个答案:

答案 0 :(得分:2)

这是你正在寻找的吗?

<?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