1

I would like to display a system message from a custom HTML module.

I have sourcerer installed which is allowing me to add php code into the module and this seems to be running fine.

However, it does not seem to execute the code to generate a system message.

Could anyone suggest a way I could get the custom HTML module to generate a system message?

My code currently looks like this:

{source}
<?php
  $msg = 'Very helpful message';
  JFactory::getApplication()->enqueueMessage($msg, 'message');
?>
{/source}
2

A common reason for plugins not working in Custom HTML modules is that they are not processed by Joomla Content plugins by default.

In order to enable this, go to the Options tab in your Custom HTML module and set "Prepare content" to Yes:

Prepare content settings

Now save your module, and the Very helpful message should be displayed, enlightening your users :)

| improve this answer | |
  • Thanks @johanpw, my users are now enlightened and have their message! That's working now. :0) – Hannah Smith Jun 17 '15 at 12:28
1

I have copied and pasted your code as it was on my site to test and it works perfectly fine.

Your template could be the reason why you're not seeing it.

Open the following file:

templates/YOUR_TEMPLATE/index.php

and check for the following code:

<jdoc:include type="message" />

If you do not see it, add it where you would like the messages to be displayed. Note the above code should not be wrapped in PHP tags

| improve this answer | |
  • Interesting... I definitely have <jdoc:include type="message" /> as I can call system messages from other parts of my site. Hmmm.... I have a custom template so shall try it with another template and see what happens... – Hannah Smith Jun 16 '15 at 10:14
  • @HannahSmith - Yes, that would be a good idea ;) – Lodder Jun 16 '15 at 10:15
  • I just tried two other templates - protostar and another called JSN Megazine PRO and neither of those show the system message from the custom HTML module. But I can see the system messages generated by other parts of the site in those templates. Weird. Not sure what to try next... – Hannah Smith Jun 16 '15 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.