user3544484
user3544484

Reputation: 851

Joomla v3 multiple PHP IF's in one statement

In Joomla v3, I want to do the following:

'countModules' the module with the following, to see if a module is assigned:

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

But I also only want to show the module position on article pages only, not category blog pages using the below:

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

How do I put both of the above IF's into 1 statement around the following so that the module position doesn't show & the div is removed only on the category blog page (but shows on article pages):

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

Upvotes: 0

Views: 86

Answers (1)

Lodder
Lodder

Reputation: 19733

Is this what you're looking for?

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

Also removed the old deprecated JRequest you were using and instead uses JApplication

Upvotes: 2

Related Questions