Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Hide columns on specific joomla article

Hide columns on specific joomla article

Hello,
i'm sorry if i ask about obvious things, but i'm really a newbie in metamod. I have virtuemart installed. I need to hide left and right columns (modules on top and bottom should stay) on a specific joomla article (not virtuemart page) and i don't want to change module appearance on virtumart pages.
Your help is very much appreciated!
I use:
Joomla 1.5.22 VirtueMart 1.1.7

dup
Beginner Modder
ranks
useravatar
Offline
15 Posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

Hi dup,

for completely hiding left and right columns in this case, I'd almost recommend making a small change to your template instead of using MetaMod... not that you can't do it with MetaMod, but it might be cleaner, as long as you aren't intimidated by the PHP in your template.

I'll show you both ways though.

1 - without MetaMod:

In your template you probably have some lines like the following, which was taken from the built-in "ja_purity" template:

<?php if ($this->countModules('right')): ?>
<!-- BEGIN: RIGHT COLUMN -->
<div id="ja-col2">
  <jdoc:include type="modules" name="right" style="jarounded" />
</div><br />
<!-- END: RIGHT COLUMN -->
<?php endif; ?>

We would change the first line to include a check for whether the particular article is showing. Change that 1st line to this:

<?php if ($this->countModules('right') and ! (JRequest::getVar("option") == "com_content" and JRequest::getVar("view") == "article" and JRequest::getInt("id",0) == XXX )): ?>

(replace XXX with the article ID of the article that you want the column to disappear from).

Then make the same modification for the left column.


2 - using MetaMod Pro

The advantage of this version is that you don't need to make any changes to the template, and it will work with ANY template. The previous version might not work in some of the more complex commercial templates that use template frameworks (JA T3, RocketTheme Gantry, etc).

You need the Pro version to do this, because it involves turning OFF modules that are not directly inside the MetaMod. This only works in the Pro version.

First, get hold of the ID numbers of the particular modules that you want to remove from the page.

e.g. 101, 102, 103.

Then create a MetaMod in any module position on the page, and use the following rule in it, replacing XXX with the article id

// add extra module ids to following array as appropriate:
$modules_to_remove = array(101, 102, 103);
if (! $content_genius->check("article_id = XXX")) {
  foreach ($modules_to_remove as $mod) {
    $changes->mod( $mod )->disable();
  }
}


Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

Thanks!
i went ahead and bought metamod pro and did all what you told me, but all that modules which i want to remove are still there.
This is the code which i pasted into PHP field in the metamod Module Parameters

// add extra module ids to following array as appropriate:
$modules_to_remove = array(35, 47, 52, 78, 83, 45, 63, 36, 65, 21, 19, 53, 90, 54, 18, 48, 92, 79, 17, 91);
if (! $content_genius->check("article_id = 88")) {
  foreach ($modules_to_remove as $mod) {
    $changes->mod( $mod )->disable();
  }
}

Please help!

dup
Beginner Modder
ranks
useravatar
Offline
15 Posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

just discovered that it took opposite effect: on all other pages that modules got disabled EXCEPT the article page which i need them to be disabled on. So obviously it's one setting somewhere which i should toggle.

dup
Beginner Modder
ranks
useravatar
Offline
15 Posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

Yep - it's this line in the recipe above:

if (! $content_genius->check("article_id = 88")) {

The "!" means "not...". So it's checking if the article id is NOT 88.

So just remove the "!" and you'll be checking if the article id IS 88.


e.g.

if ($content_genius->check("article_id = 88")) {
...


Sorry I got this mixed up on the original PHP suggestion.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

thanks!
that works!

dup
Beginner Modder
ranks
useravatar
Offline
15 Posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

Hi, this thread was helpfull, i used the first option :


<?php if ($this->countModules('right') and ! (JRequest::getVar("option") == "com_content" and JRequest::getVar("view") == "article" and JRequest::getInt("id",0) == XXX )): ?>

And if it wont be a problem, how can i set multiple articles in place of "XXX"  not just ONE but few. Or eventually to one whole category of articles. Thx for help.

zen32
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Hide columns on specific joomla article

This is how you would edit the template (not using MetaMod Pro) if you want to check for more than one article:

<?php
$my_id = JRequest::getInt("id", 0);
if (
  $this->countModules('right')
  and ! ( JRequest::getVar("option") == "com_content"
       and JRequest::getVar("view") == "article"
       and ( $my_id == XXX or $my_id == YYY or $my_id == ZZZ )
      )
  ) :
   ?>

<!-- BEGIN: RIGHT COLUMN -->
<div id="ja-col2">
  <jdoc:include type="modules" name="right" style="jarounded" />
</div><br />

<?php
endif;
?>


When it comes to doing this by category I'd suggest using MetaMod, since there are built-in functions for getting the category of the currently displayed item.

Cheers,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3312 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1667
Total Polls:
6
Total Posts:
5909
Posts this week:
1
User Info:
 
Total Users:
10112
Newest User:
chris28464
Members Online:
0
Guests Online:
171

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked