Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



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


Hide/Show module whenever tinyMCE editor is called

Hide/Show module whenever tinyMCE editor is called

Here's the problem: When editing an article through the frontend via the edit icon, tinyMCE opens on a page without a menu linking to it, so Joomla module display options do not apply. In my case, this means two modules on the right are pushed out of the template area with no way to hide them as I have done on my 'submit article' page which is menu linked. Is there a way to use metamod to hide certain modules whenever the editor is called, no matter what page one is on? Or am I missing some sort of method to solve this through Joomla itself? If metamod can do this, what might the recipe be?

Beginner Modder
2 Posts
Administrator has disabled public posting

Re: Hide/Show module whenever tinyMCE editor is called

Hi brotherhutch,

To investigate this I turned on the new "advanced" debug mode in MetaMod, with the MetaMod assigned to "all" pages. Then I logged into the front end and clicked on an article's edit icon.

It gave me the following rule:


if ( 

$option == 'com_content'
and $view == 'article'
and $id == '5:joomla-license-guidelines'
and $Itemid == '85'
and JRequest::getVar('ret') == 'aHR0cDovL2xRoZS1wc... ... Jkl0ZW1pZD04NQ=='
and JRequest::getVar('task') == 'edit'
) return XXX; /* replace XXX with the module ID or position to display */

From that I can see that this particular article *does* have a menu link (Itemid 85), though that might be different for yours.

The big "ret" string is going to be some long encrypted string, so we'll ignore that for the purposes of identifying the page.

What we're left with is $option = 'com_content', $view = 'article', and  JRequest::getVar('task') == 'edit'. You could use the id of the particular page being edited to make decisions too, but that's not what you asked for.

It's really important to note that the rule that we make with these variables ONLY detects whether this particular page was *requested*. It does not guarantee (or detect) whether or not the person was authorised to edit the page. You might argue that all we are going to do based on this information is to hide some modules and that it doesn't matter if someone tries to "spoof" your rule by requesting a page edit even when they are not authorised. However, I am going to add part of a rule to ensure that *at least* a person is logged in. So if a non-logged-in user adds '&task=edit' to the page URL it won't turn off the modules in the right column.

- we have to put all the modules that you want to put into the right column into a different module position, so that we can control them with the MetaMod.
- so re-assign the 2 modules into a new module position called "right-metamod".
- then create a MetaMod and assign it to "ALL" pages, in the "right" module position.
- then use the following rule in the PHP section of the MetaMod:


if ( !($option == 'com_content'

and $view == 'article'
and JRequest::getVar('task') == 'edit'
  return "right-metamod";

What that does is says "if we are not on the page described by this rule, then put all the modules from "right-metamod" into the current module position (right). Rule: option=com_content, view=article, task=edit, user is logged in".

This will work irrespective of what menu item you are on, since we are not identifying based on Itemid (and we are doing this on "all" pages).

The only problem you are likely to come across with this approach is that depending on your template, you might find that there's an "empty" right column appearing instead of "no right column at all". This can happen because there's still a module assigned into the "right" position -- the MetaMod itself, even if it's not including other modules. Many templates reserve extra space in the left and right columns (and sometimes other module positions) if they know that a module is assigned there.

The best way to get around this is with MetaMod Pro, which completely eliminates empty MetaMods from a module position. This makes left and right columns collapse properly in this situation.

Hope that helps,

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

3312 Posts
User info in posts
Administrator has disabled public posting

Re: Hide/Show module whenever tinyMCE editor is called

Wow this is really thorough! Thank you.  I'll try this out next time I'm working on the site. I also discovered something strange: If I set the tinyMCE toolbar option to 'bottom' suddenly the editor area auto-adjusts to take up only the centre column leaving the modules on the right side, within the bounds of the template (rhuk_milkyway) where they should be.  This means the editor is a little cramped, but at least it looks okay.  With your fix though, I should be able to get the wider editor with toolbar at the top. Thanks again!

Beginner Modder
2 Posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Posts this week:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

Forum Legend:

 New Sticky