Use MetaMod to put modules into different positions on different templates
If you use more than one template on your site, you have probably run into this issue: different templates often use different names for their module positions. “top” in one template might be called “header” in another.
So how do you get a module to appear in the position “top” in one template, but “header” in another? Read on to find out how MetaMod can solve this for you without having to hack any template code!
A MetaMod is a module “placeholder”. You assign it into a module position, then it is able to make decisions about which modules it will display inside itself. It can include individual modules, or pull in all the modules from a different module position. This makes it great for the situation where you’re using different templates with different names for the different module positions.
So, let's say you have 4 main places where you want to put your modules. Let's call them top, left, right and bottom. I'm going to call these “virtual module positions”. These are where you’re going to assign your modules, even though these may not correspond to the actual names of the module positions in the templates.
You might have 2 templates, and the corresponding module positions may be named:
You would then create a MetaMod for each of the 8 module positions in the 2 templates. Don’t put any of your other modules in those positions. Just have 1 MetaMod in each position.
In the configuration of each MetaMod there's a box called “Quick module id or position include”. Into that box you type either top, bottom, left or right, depending on which “virtual” module position it’s going to pull the modules from.
What happens when you view a page?
When you view a page with template 1, the template looks in module position “header”. It finds only the MetaMod and displays it. Here’s the clever bit... the MetaMod grabs all the modules from your virtual position called “top”, and displays them here instead.
The same will happen with template 2 when it displays the “topbar” position – it will grab all the modules from your virtual position called “top” as well.
Using this technique allows your modules to appear in different module positions on different templates. You don’t have to duplicate your modules. And you don’t have to hack your template to change the module positions.
This technique is great for the workflow of the people creating modules. All they have to remember is to allocate modules to top, bottom, left or right, and the system will take care of exactly which actual module position these will go in, in each case.
It’s also useful to combine this with other selection criteria. e.g. if you have certain modules which should be shown to people from a certain country, you could use a virtual module position called right-usa. Then you could add a second MetaMod to your "top-right" and "content-right" positions, that pulls in the module position right-usa when GeoIP detects that the viewer is from the USA. Again, this is great for the work-flow of people creating modules on your site. They don’t have to worry about the technical side of module selection – all they have to remember is that if they want a module to only appear for people in the USA, they should put this into the right-usa position instead of the right position.