2

I have a Joomla v2.5.14 application and I'm in a situation that I need to hide a menu item from the users based on a database value, basically what I need is to hide the menu item based on a condition.

My question is, where's the right place to perform this? and how to do it?

2
  • 2
    Please update to Joomla to 2.5.28. You're leaving yourself and your users vulnerable. Luckily you haven't provided a link to your site, else it could take anyone less than 15 minute to hack. Please then consider migrating to Joomla 3.x
    – Lodder
    Commented Mar 22, 2016 at 16:00
  • Once you've updated to 2.5.28 remember you also need the Session Hardening Patch which can be downloaded from: docs.joomla.org/Security_hotfixes_for_Joomla_EOL_versions Commented Mar 23, 2016 at 1:23

1 Answer 1

3

Assuming the menu option has a suitable CSS selector e.g. "item-135", it could be hidden via CSS.

You could create a custom HTML module to add the appropriate code to the applicable page(s). Set the custom HTML module position to "debug" or similar if your template has this option (as the debug module position is less likely to have any margins or padding associated with it).

Install and enable the Regular Labs Sourcerer plugin or similar so the code is not stripped from your Custom HTML Module.

In the Custom HTML Module, your code will look something like this:

{source}
  <?php
    if ([some condition]) {
      $document = JFactory::getDocument();
      $style = '.item-135 {display: none;}';
      $document->addStyleDeclaration ($style);
    }
  ?>
{/source}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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