Joomla Tip: Add New Module Positions Inside a Component

Do you know that you can display modules inside components? This is possible with a single line of PHP code.

In this tutorial, I'm going to show you how to display a module inside any component.

We will use the articles component for this example. However, this approach works for any component.

Step #1. Create a template override

Let's create a template override to place our customizations safely.

  1. Go to Extensions
  2. Templates
  3. Templates (child menu)
  4. Your template details and files


We are about to create a template override for single articles.

  • Now go to the Create overrides tab.
  • In the "Components" column, click on com_content > article. A set of files will be generated in the folder /templates/your-template/html/com_content/article/


Step #2. Edit the template override

  • Go to the Editor tab
  • Find the file default.php inside the /com_content/article/ folder
  • Add the custom php code below where position-name means the name of your custom module position:
    <?php echo JHtml::_('content.prepare', '{loadposition position-name}'); ?>


  • Click Save and close when you're done

Step #3. Create a new module

Let's test our custom module position.

  • Go to Extensions > Modules > Add new.
  • Choose the module type you want. In our example, we're going use a Custom HTML module.
  • Type the new module position in the Position parameter, and press the Enter key. In this case, we're using position-name.
  • Under "Menu Assignment", make sure the module is enabled for all the pages.
  • Save and close the module.


Step #4. End result

Preview one of your full articles in the frontend of your site. The module should be visible somewhere inside the article layout.


Have problems showing modules inside articles?

  • Go to Extensions > Plugins.
  • Make sure the plugin Content - Load modules is enabled.


About the author

Valentín creates beautiful designs from amongst the tequila plants of Jalisco, Mexico. You can see Valentín's design work all over this site and you can often find him helping members in support.