15 October 2015

Modules: Add Support for Content Plugins

Written by Valentín García, Posted in Advanced,

Modules: Add Support for Content Plugins

As a developer, once in a while I get requests to integrate content plugins inside modules that display articles.

By using a plugin, we expect to render video players, galleries or snippets inside the article, however the module may not include the necessary code to accomplish this action.

In this tutorial you will learn how to support content plugins inside modules.


The scenario

Let’s say I have a module that display the introduction text of a few articles. Inside every item I typed a shortcode that should be converted into an image, unfortunately the plugin can't reach my module.

My frontend only expose the shortcode.


Create the template override

Let's solve the problem with template overrides.

Even you can edit directly the code from the module in modules/mod_yourmodule/tmpl/default.php (it can be another filename.php) however it’s highly recommended to create a template override to have the next customization by separate.

In your backend, go to Extensions > Templates > Templates (on the left side) > Your template details and files


  • Create overrides tab
  • Look for the module in question and click on it


This action will generate a file (or a set of files) in templates/your-template/html/mod_yourmodule/

Edit the template override

  • Go to Editor tab
  • Navigate through html > com_yourmodule > default.php or something.php


Look for the line of code that print the introtext (introduction text). The syntax would depends on how the module is coded.

Don't expect your code to be exactly the same from my example.

In my case is:

echo $article->introtext;


Replace that line with:

echo JHTML::_('content.prepare', $article->introtext);


In the previous lines $article->introtext contains the article’s introduction.

Note: if your module print the full article, the code would work too.

Test the end result

Refresh your public site to see how the plugin convert the shortcodes into cute images.



About the Author

Valentín García

Valentín García

Web developer and designer that love building sites with Joomla. Currently working at OSTraining as Director of Design.