1

One of my clients wants to display a message for SEO purposes on each page (menu item) and I know this can be easily solved with several modules of the type "custom html" each one assigned to its corresponding menu item.

But they have a lot of menu items meaning equal number of modules.

I was wondering if there is an easy way to do it and I have two ideas:

1 - Have an extra field in the menu item to add the text and develop a module that read that extra field and render it in the page. I can develop the module but I don´t know how to add an extra field in the menu item form without using overrides. ¿is there a way to do that?

2 - Develop a module that allow you to choose menu item and message in a repeteable form. I can program this but I would like to ask if someone knows of a module that have this fucntion so I can spare the programming (I already search the JED)

Thanks for your help

3

Option 1

A quick way to do this is to install Regular Labs Sourcerer (or similar) and use a Custom HTML module with similar code to the following:

{source}
<?php
$app = JFactory::getApplication();
$itemid = $app->input->getCmd('Itemid', '');
switch ($itemid)
{
case '131':
  echo "<p>Message 1</p>";
  break;
case '132':
  echo "<p>Message 2</p>";
  break;
case '133':
  echo "<p>Message 3</p>";
  break;
default :
  echo "<p>Message 4</p>";
  break;
}
?>
{/source}

Enter menu IDs with the corresponding messages in a switch statement. You could include a default message in case you missed a page.

Option 2

Keywords meta data has little value these days (from an SEO perspective) so you could hijack this field for your own purposes by installing Regular Labs Sourcerer (or similar) and using a Custom HTML module with similar code to the following:

{source}
<?php
$doc = JFactory::getDocument();
$keywords = $doc->getMetaData('keywords');
if ($keywords) {
  echo "<p>" . $keywords . "</p>";
  $doc->setMetaData('keywords', '');
}
?>
{/source}
  • Hi, this is a great solution for me, but my customer should not do any PHP at all. Thanks. – Piero Marsilio Jan 11 '17 at 15:31
  • OK, I have added an additional option. – Neil Robertson Jan 11 '17 at 21:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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