How to Run Joomla Content Plugins in Custom HTML Modules in Joomla 4

If you are using Joomla 3, please refer to the article: How to Run Joomla Content Plugins in Custom HTML Modules

Plugins such as DirectPHP, googleMaps and googleDirections are called content plugins.

As the name suggests, content plugins run inside Joomla articles, or the com_content component.

If you're using Joomla 4.0 and above, it's now very easy to run content plugins in Custom HTML Modules.

  1. In the Left Menu, click:
    Content > Site Modules > New
  2. enable-content-plugins-in-custom-html-modules-joomla4-01

  3. Select Custom:
  4. enable-content-plugins-in-custom-html-modules-joomla4-02

  5. Enter your module name in Title.
    Suppose you're using the DirectPHP plugin, enter the code in the text area of the module.
    If you are using the default Joomla 4 installation, select "Sidebar-right" in Position.
    Also make sure that the module is Published.
  6. enable-content-plugins-in-custom-html-modules-joomla4-03

  7. Go to the 3rd tab "Options". Set the 1st field "Prepare Content" to "Yes".
  8. enable-content-plugins-in-custom-html-modules-joomla4-04

  9. Click "Save and Close".

Your plugin should now run inside your custom module!


Take for example, if you are using the DirectPHP plugin and the PHP code does not run in the module, please try the following:

  1. First thing first, make sure that the plugin works on your joomla website. All you need to do is to create a new article and place the tag in the article. Save the article and load the article in your joomla. If the PHP code runs in the article, it means that the plugin is working.
  2. Note that plugins such as DirectPHP, googleMaps and googleDirections are all content plugins.. As the name suggests, they are originally designed to work within a content article. If the plugin does not work in a content article, it WILL NOT work in a module. So always test your tag in a content article first.

  3. Now that your are sure that the content plugin is working fine, place the same tag in a custom HTML module. Go to Module Manager and make sure that the following are set correctly:
    1. The module is enabled or published.
    2. You have selected the correct module position.
    3. In "Menu Assignment", make sure you have selected "On all pages" or "Only on the pages selected"
    4. In "Options", you have changed "Prepare Content" to "Yes" as described in the previous section.
    5. Don't forget to save.

  4. If the PHP code still does not run, then you may want to try clearing the cache.
    • You need to clear the cache for on your Joomla server side (especially if you are using some cache plugins).
    • You also need to clear your browser cache and do a reload.

Add comment

Security code