How to Run Joomla Content Plugins in Custom HTML Modules

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

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 3 and above, it's now very easy to run content plugins in Custom HTML Modules.

  1. Create a new Custom HTML Module (or Edit an existing module):
    Extensions > Modules > New > Custom HTML
  2. Suppose you're using the googleMaps plugin, enter the code in the text area of the module:
  3. enable-content-plugins-in-custom-html-modules-1

  4. Go to the 4th tab "Options". Set the 1st field "Prepare Content" to "Yes".
  5. enable-content-plugins-in-custom-html-modules-2

  6. Click "Save and Close".

Your plugin should now run inside your custom module!

Troubleshooting

Take for example, if you are using the googleMaps plugin and the map does not appear 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 google maps appear 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 map still does not appear, 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.

Comments   

+3 # Francesco 2016-08-19 10:32
Very useful plugin!
I'm using it in a Custom HTML Module.
Thank you very much!
Reply | Reply with quote | Quote
+2 # Kaz 2017-07-19 13:52
Hi,
I can't get the maps to display in my latest J! installation. I am using {googleMaps lat=-33.855672 long=151.172872 label="Nicolsons Electrolysis" label=”Nicolsons Electrolysis” width=180 height=200 addscale=1 addoverview=0 add_p=1} but the map does not display in the module. I;ve tried deleting my browser cache. Any suggestions?
Thanks in advance.
Reply | Reply with quote | Quote
0 # kksou 2017-07-20 01:31
Hi Kaz,

Just tried your code on my test website. It's working fine.

Please refer to the troubleshooting guide here: https://www.kksou.com/php-gtk2/joomla/how-to-run-joomla-content-plugins-in-custom-html-modules.php#troubleshooting

Please give the above a try and let me know if it works.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
0 # Kaz 2017-07-20 07:38
Hi kksou,
Thank you for your expedient reply.
I did try searching for a solution before posting and eventually found that I needed to add additional code between the head tags of my template index file to address a https/ssl issue arising from the google maps javascript api calling a http rather than https request.
As usual, this occurs a short time after I post for help on a forum :|
Once again, thank you and best regards and success with your app :D
Reply | Reply with quote | Quote
-4 # kksou 2017-07-20 08:07
Hi Kaz,

Glad you've got it to work!

Quote:
"to address a https/ssl issue arising from the google maps javascript api calling a http rather than https request"
Think you may be using the older version.

You may want to install the latest version of googleMaps (v3.0.30) which will give support for https/ssl site.

The latest version also adds support for the Joomla Update System. What this means is that once you have installed this version, Joomla will inform you whenever there is a new version of googleMaps. You can simply update the plugin from within the Joomla backend at the click of a button.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
-4 # Kaz 2017-07-20 08:25
Quoting kksou:
Think you may be using the older version.
You may want to install the latest version of googleMaps (v3.0.30) which will give support for https/ssl site.


How do I tell?
Thanks in advance.
Reply | Reply with quote | Quote
0 # kksou 2017-07-20 08:30
Hi Kaz,

1. Logon to Joomla backend
2. Select Extensions - Manage (from top menu)
3. On the Left Menu, click "Manage"
4. Search for googleMaps. You will see the version number listed there.

Please give the above a try and let me know if it works.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
+1 # Kaz 2017-07-20 08:36
Hi kksou,
I updated the plugin and now the map has vanished again. I tried removing the script in the head of the template but that did not fix the issue. Any suggestions?
Thank you in advance.
Kaz
Reply | Reply with quote | Quote
+1 # Kaz 2017-07-20 08:38
Apologies.
My server just made a liar of me. It is now working.
Thank you for your patience with me. :roll:
Reply | Reply with quote | Quote
-1 # Guilherme 2017-08-03 18:03
Hi!
I just installed your DirectPHP plugin but I am not sure how can it help me to achieve the following objective: I need to create a custom HTML module on Joomla website mywebsite.com that will display another Joomla module from myotherwebsite.com.
Both websites are on the same server, even though I don't think this makes it easier or not.
So, I thought I could use DirectPHP plugin in order to write some PHP on a custom HTML module with an inclue or required command but I am not sure how to do this.
Any suggestions?
Tks a lot!
Guilherme
Reply | Reply with quote | Quote
+3 # kksou 2017-08-08 06:57
Hi Guilherme,

I wrote DirectPHP as a simple way for me to insert simple PHP codes into Joomla article.

What you want is a lot more complicated than what DirectPHP is designed to do. It can be done if you are very familiar with both PHP and Joomla. But if you're not, I would suggest not to, because it involves accessing another website, and maybe the mysql of another website. If not done carefully, and you did not switch back to the mysql of your original Joomla website, you will see only one blank screen. Yes, only one blank screen with no warning or error messages at all.

If you can code this using DirectPHP, it means you know PHP and Joomla very well. In that case, I would suggest you write your code directly as a Joomla module or plugin. It's so much cleaner and easier, especially for debugging purpose.

Warm Regards,
/kksou
Reply | Reply with quote | Quote
+3 # Guilherme 2017-08-03 18:07
Hi!
I have another question regarding DirectPHP plugin block feature: if I block all PHP commands excep the ones I do use inside content or custom HTMLs modules (if this is possible), will the plugin block ALL PHP or just PHP existing in my content articles and/or HTML modules?Tks a lot!
Guilherme
Reply | Reply with quote | Quote
+2 # kksou 2017-08-08 06:58
Hi Guilherme,

It only blocks the one that you use inside DirectPHP.

Warm Regards,
/kksou
Reply | Reply with quote | Quote

Add comment


Security code
Refresh