Quantcast
Channel: How-to – Rushtips.com
Viewing all articles
Browse latest Browse all 23

How-to: Add Module To Component & Article [Joomla]

$
0
0
modulePosition1.png

If you, like me, use a keywords plugin to categories your articles, it can be hard to add a module to the article-page only and not the homepage. I found a very easy way to load the module inside the component of your choice, in this case components/com_content/views/article/tmpl/default.php. I’ll also give you a tip on how you can add a module inside an article.

How to Add the Module to a Component

To add the module to component this is what you have to do.

The share-grid to the left is a module added to the component article. Just add this code to the end of components/com_content/views/article/tmpl/default.php. And the module will only be displayed in the article and not on the homepage.

<div id="share">
          <?php
          $zone = "share";
          $modules =& JModuleHelper::getModules($zone);
          foreach ($modules as $module){
             echo JModuleHelper::renderModule($module);
          }
          ?>
</div>

How to Add the Module to an Article

modulePosition1   How to: Add Module To Component & Article [Joomla]

Lets say you want to add a module to the middle of an article. Can it be done? Well, of course! Copy the module you want to use and/or change it’s position to something that you haven’t used before, for example – “inarticle”. Then just add this code to the article you want the module to render in.

{loadposition share}

And that’s it. Let me know if this was to any help!

flattr this!


Viewing all articles
Browse latest Browse all 23

Trending Articles