8

Is it possible to display a module in multiple positions, preferably natively, or through a third party extension?

I know there are workarounds...

  • clone the module and change the position, however this is tiresome if the module contains, say, custom HTML and this is likely to change often.
  • use load syntax to drop module wherever you want, but still results in modules being created simply to hold other modules

but both create extra maintenance work that I'd rather forego.

1

You could use nonumbers modules anywhere.

http://www.nonumber.nl/extensions/modulesanywhere/userguide

Unlike the loadposition version that is in the core, it can be used in a module as well and not just an article. So you could make a second custom html module, and then call the first position. This would basically give you a copy of the position, but what ever settings you change in the first module will also apply in the second "clone".

  • Cheers for taking a look @Jordan, but you can do this without Modules Anywhere - see docs.joomla.org/How_do_you_put_a_module_inside_an_article%3F (the custom HTML module accepts the load syntax if you set Prepare Content to 'Yes'), thus falling under my 2nd workaround. – codinghands Oct 21 '14 at 15:08
  • hmm, good note, my experience has been that that did not work, could of been a bug in the specific version I tried it in. Have not really tried since. – Jordan Ramstad Oct 21 '14 at 15:12
  • The problem with modules anywhere is that it doesn't do any caching (see our experience with it here: itoctopus.com/… ). This means that for heavy modules will always be re-created again and not just grabbed from the cache (even if a cache file for that file exists). – itoctopus Sep 1 '16 at 21:23
1

I suggest building a simple plugin, and use something like this to publish the module to several positions (using a loop):

$document   = &JFactory::getDocument();
$renderer   = $document->loadRenderer('modules');
$options    = array('style' => 'xhtml');
for ($x=0; $x<=5; $x++) {
     $position   = 'myPosition' . $x;
     echo $renderer->render($position, $options, null);
}
// Repeat for each module position, changing only $position

(Not tested)

I'll see if I can put together something more complete later today.

1

At a simple level you can try this:

If this is going to be a single module and you have already defined where you want to display it, you could create a special module position in your template and make 2 or as many as needed calls for it, at the locations you want in the template. It will load the modules of that position wherever you call it.

If there are more modules and for more positions you want to apply this, the above approach may still be fine, unless if you need more control or complex appearances of the modules, something that might require "smarter" creation of module positions and calls for the modules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.