MetaMod Position Display Management

When using Joomla! sometimes one requires to hide some information, like a specific menu, or an entire position.

MetaMod let’s you do this in a quite easy way. One can follow their documented technique of moving stuff from an non-existing position into the real position, or one can use a simpler strategy that does not imply having virtual positions and nor moving stuff between these virtual positions and the real position.

Imagine you wish to hide all position placeholders on a marketing landing page. It’s quite easy:

  • Download and install MetMod. Don’t forget to read the documentation to know how MetaMod works.
  • The first step is to define the MetaMod position in the last one to be interpreted by Joomla!, usually the footer or the debug.
  • This guarantees that our code will be executed only when all positions are already loaded.
  • The second step is to define the MetaMod execution rules, as stated in the documentation.
  • Next, in the PHP window, include the execution code that will hide or display the position through the injection of a Javascript conde snippet.

Here’s an example: let’s say that one wishes to hide the stuff on the left of the page (usually the menu, login, etc.) when the user is located in the Virtuemart Cart plugin.
Here’s what one has to do:

  1. Identify the location through the $option and $view parameter values.
  2. Inject a Javascript script that finds the left position element and hides it.
  3. If required, adjust the size of the remaining position in order to claim the extra space.
  4. Return the current position.
Here’s an example that hides the “column_left” position. Please note that this MetaMod example is located in the “debug” position, change it if necessary.
if ($option == 'com_virtuemart' and ($view == 'cart' or $view == 'pluginresponse'))
{
echo "
 <script>
   elem = document.getElementById('column_left');
   elem.style['display']='none';
   elem = document.getElementById('content_wrap');
   elem.style['width']='960px';
 </script>"
;
}

return 'debug';

Obviously this must be adapted to the template in use and it may required some adjustments, like the new size of the position that should claim the extra space.

One can use Firebug to help finding the HTML div elements identifiers involved.