1

I am assigning a php module on different menus on my Joomla website, but I want the module to show different data when loaded on different menu pages.

Example : There is parent menu Home and three sub-menus, Sub-menu1, Sub-menu2 and Sub-menu3.

When user browses sub-menu1 page, the module should load "Welcome to Sub-menu1" and when the user is on sub-menu2 page, the module should load "Welcome to sub-menu2" and so on. I have around 200 sub-menu pages on my Joomla website and I don't want to assign 200 individual php modules for them. I guess it would require an IF/ELSE condition but are there any specific ID's allotted to the Joomla menus? If yes, how can I retrieve the data (menu IDs) while loading the module and use the IF/ELSE condition?

P.S I have already imported the Joomla CMS (Joomla 3.4.8) using this :

define( '_JEXEC', 1 );
define( 'JPATH_BASE', realpath(dirname(__FILE__).'/' ));  
require_once ( JPATH_BASE .'/includes/defines.php' );
require_once ( JPATH_BASE .'/includes/framework.php' );
$app = JFactory::getApplication('site');

Help would be appreciated!

3

You can use the following to display the desired message:

$app   = JFactory::getApplication(); exist
$menu  = $app->getMenu();
$title = $menu->getActive()->title;

echo 'Welcome to ' . $title;
  • I had posted an example in my post, I don't need the title name only. I need to run alot of code for every particular menu, that's why I had mentioned it might require IF/ELSE. – saibbyweb Apr 2 '16 at 8:31
0

Use the input given to the application that ultimately controls which page is displayed and therefore which sub-menu is shown

This may not be the "Joomla" way to do things I am relatively new to Joomla anyway use the:

JFactory::getApplication()->input

Object documentation on this JInput object can be found on the Joomla document site but if in doubt there are your standard php debugging tools like

var_dump($var)

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.