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.
- In the Left Menu, click:
Content > Site Modules > New
- Select
Custom
: - 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. - Go to the 3rd tab "Options". Set the 1st field "Prepare Content" to "Yes".
- Click "Save and Close".
Your plugin should now run inside your custom module!
Troubleshooting
Take for example, if you are using the DirectPHP plugin and the PHP code does not run in the module, please try the following:
- 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.
- 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:
- The module is enabled or published.
- You have selected the correct module position.
- In "Menu Assignment", make sure you have selected "On all pages" or "Only on the pages selected"
- In "Options", you have changed "Prepare Content" to "Yes" as described in the previous section.
- Don't forget to save.
- 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.
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.
Read more...