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.

 

How can I hide a module during "read more.."?

How can I hide a module during "read more.."?

My problem:
I have a site where each main menu topic has it's own three modules shown at the bottom of the page (Custom HTML, in positions user6, user7 and user8). The bottom modules are short ingresses to longer  contents that give more insight to various aspects of the contents of the page they are shown on. When you klick on the header or the read more link in the modules, the entire module content text will show in the main content area. As the menu topic stays active, the same three modules are still shown at the bottom, including the one currently being read.

Question:
Is there any way to hide the module that shows the ingress of the text currently being read without making a complicated set of rules using article id's? Or even better to replace that module with some other module?

tekfix
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: How can I hide a module during "read more.."?

Hi tekfix,

Since the module ids of the "teaser" modules and the article ids of the articles they point to are not related, the most straight forward way of doing this would be to what you said you don't want to do - a series of rules based on the article ids. You're right, it would be a bit of a management hassle, depending on the number of modules and articles you are dealing with.

It would be easier if you simply didn't want to show ANY of the teasers on the article view pages. However I think you're saying you only want to hide the module that's related to the actual page you're on.

A better approach
The other approach I can think of would be to use a different kind of module, not "Custom HTML" but one that can display the intro text of an article that it's pointing to. There's one called "mod_content":

http://code.joomla.org/gf/project/mod_content/frs/

There are other similar modules here:

http://extensions.joomla.org/extensions … tent-embed

The advantages of doing this are:

1 - it may be easier to manage the content itself, since you only have to edit it in one place, the article, then the intro text shows up in the module automatically.
2 - you now have a link between the module and the article, in that the module parameters hold the article id of the article it's pointing to.

So, the idea takes shape...

You create 3 "blank" mod_content modules. Set them to "menu items: none", but otherwise set them up as you want them to display. It doesn't matter what article you tell them to display at this point, as we're going to override that.

These modules are going to get re-used for every page.

Then you create 3 MetaMods, 1 in each of the module positions.

You will use a rule in each one that does this:
1 - detects what menu item it is on
2 - looks up which article intro it is going to display
3 - detects if it's already on that article page. If so, doesn't display a module.
4 - if it's not on the article page that it's going to point to, then it pulls in the mod_content module and tells it which article to display the intro for.

Here's how this could look:

Code:

// 1 - menu item is already held inside $Itemid so we don't need to look it up.

// 2 - look up the article id to display.
// We'll make an array that maps Itemids to articles for the 1st module position.
// You'll need to make a separate one for each module position.
$articles = array(
  20 => 200, // Itemid 20 will display article 200
  21 => 201, // Itemid 21 will display article 201
  22 => 202, // Itemid 22 will display article 202
  22 => 203  // Itemid 23 will display article 203
// add more as appropriate
);
$article_to_display = @$articles[ $Itemid ];
// short-circuit (display nothing) if we didn't get an article:
if (! $article_to_display) return;

// 3 - are we already on that article page?
// If so, short-circuit and display nothing.
if ( $content_genius->check("pagetype = article")
  and $content_genius->check("article_id =",$article_to_display) ) {
    return;
}

// 4 - use one of the com_content modules to display the article intro.
// We will set a parameter in the module tell it which article to display.
$module_id = 1000; // EDIT THIS! Needs the id of the 1st com_content module.
$changes->mod($module_id)->setParam("id", $article_to_display);
return $module_id;

There are just 2 places where you need to customise this:
a- the list of menu ids (Itemids) and which article goes with each one
b- the $module_id for this module position. This will be one of the 3 "template" modules that you set up.

You just need to make 3 of these MetaMods, one for each module position.

Just a note about the line that says this:

$changes->mod($module_id)->setParam("id", $article_to_display);

... the setParam() method is part of MetaMod. It allows you to change a parameter inside a module that is going to display. In this case, the "mod_content" module has a parameter known internally as "id" which determines which article to display. If you use a different content module then it may have a different parameter name. I found the parameter name inside the mod_content.xml file inside the mod_content package.

This is a very powerful technique, and allows you to control a large number of modules / articles from just 3 MetaMods and 3 template modules.

I hope that all makes sense - if you have any questions please ask.

Best regards,
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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: How can I hide a module during "read more.."?

Wow - that was a comprehensive, fast answer and it seem to be a very powerful solution! I will try it out first thing in the morning! Thank you! I will tell you how I succeed... big_smile

tekfix
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: How can I hide a module during "read more.."?

Yes, indeed - that works perfectly. A very elegant solution!  Thank you!

tekfix
Beginner Modder
ranks
useravatar
Offline
5 Posts
Administrator has disabled public posting

Re: How can I hide a module during "read more.."?

Wonderful. Thanks for confirming that it worked for you.

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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: How can I hide a module during "read more.."?

Hello Stephen,

Kindly help me. We are updating news daily in our website. I'm using k2 items listing, linked to my home menu.  In the same page i used a module mod_freeslider_sp1. When i click readmore, in the detail page the module mod_freeslider_sp1 is displayed. I want to hide that module in detail page.

Kindly help me.

Thanks,
Kousi.

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

Re: How can I hide a module during "read more.."?

Hi Kousi,

can you please install MetaMod, turn on its Advanced Debug Mode, view one of the detail pages, and send me the output of the MetaMod? This should help to identify the page so I can write some code for you.

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
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10772
Newest User:
alton29318
Members Online:
0
Guests Online:
172

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