Load module position in template override in Joomla 2.5

Just a quick one that I always struggle to find. If you have a template override in something like K2, or just a simple com_content override, then sometimes it’s useful to load a module position within the override rather than using the normal module manager and positions.

In your override pop the following code in between your PHP tags.


// This loads the module position
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('modules');
$position = "YOURPOSITIONNAME";
$options = array('style' => 'raw');
echo $renderer->render($position, $options, null);

Obviously you need the correct position published in your template. You can also add extra options is you require.

6 thoughts on “Load module position in template override in Joomla 2.5

  1. Excellent!
    Thank you for your post, it makes me to see clearly how to add a module position into a leader items template.
    Thank you again.

  2. Hi Guys, while this renders the module, it does not show the title of the module !!. How can we show the title of the module also ?

  3. Hello,

    I am trying to achieve this and I can’t seem to get it to work.

    I have created a K2 template override and I want to insert a module in the tag.php file

    I have tried using the code but nothing is shown. Here is my code:

    loadRenderer(‘modules’);
    $position = “bytag”;
    $options = array(‘style’ => ‘raw’);
    echo $renderer->render($position, $options, null);
    ?>

    Any advice would be a great help.

    Many thanks,
    Neil.

Leave a Reply

Your email address will not be published. Required fields are marked *