I'm not as expert in php, so sorry in advance (i'm using Joomla! 3.3.6 in Italian).

What I want to do / get is: - create and enable an HTML module into Joomla, with position "position-x" (which does not really exist in the template) - call this module, if a certain condition occurs, by php (in my index.php), between two specific modules in the same position "sidebar", identified by id, or by order or something.

Is it possible? I am looking for suggestion, an idea ...

Thank you very much!

1 Answer 1


Not sure if I am clear with what you are trying to achieve. But you can't call other modules to appear inside another module position - at least I am not aware of an easy way to do something like this, so you can't inject a module that is assigned to another module position in between 2 other modules of another position.

But, if you want to show that module at that position, then why don't you assign it at that position?

Also for conditions, the core module manager allows you to assign the module by menu item. If you need more flexibility, you can use the Advanced Module Manager by NoNumber.

At the other hand, if you want to make things happen from inside your template and add custom php logic, I think you will need to create different module positions for the sidebar position.

E.g. if you want to show 2 modules and under certain conditions to show one more in the middle, you will need 3 module positions:
The left, the centre and the right and you have to arrange their positioning with CSS.

Finally you can load a module from inside your template with the code below:

jimport( 'joomla.application.module.helper' );

$modules = JModuleHelper::getModules( 'myposition' ); // Get Modules assigned at a position myposition (Returns an array)- it can be a custom position. 

$attribs = array('style' => 'xhtml'); // define module attributes, like module chrome. 

if (count($modules)>0) { // Checking if there are any modules ?> 

    <!-- Module wrapper -->
    <div id="top-contentb" class="top-content">

       <?php echo JModuleHelper::renderModule($modules[0], $attribs); // Render the first module of the $modules array.?> 

<?php } ?>

Hope this helps a bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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