开发者

joomla how to access menu alias from a document

开发者 https://www.devze.com 2023-04-10 06:55 出处:网络
I have several menus that lead to the same page, but I need the page to do different things depending on the link that was clicked. (eg. site.com/monday, site.com/tuesday)

I have several menus that lead to the same page, but I need the page to do different things depending on the link that was clicked. (eg. site.com/monday, site.com/tuesday)

How do I 开发者_JAVA百科access a menu alias form a document with PHP in joomla 1.7?

Any help is appreciated. Thanks.


In the header code of your index.php file, use the following code to grab the active menu item

<?php
   $menu = &JSite::getMenu();
   $active = $menu->getActive();
?>

Later, use this to print the alias as need be

<?php print $active->alias; ?>

For example

<body class="<?php print $active->alias; ?>">


Each menu item has a Itemid, it's the ID of the item, you can see it on its details on administrator panel).

joomla how to access menu alias from a document

Tou can get and test it in PHP this way:

$Itemid = JRequest::getInt("Itemid", 0);
switch ($Itemid) {
    case 437:
        // some code for item 437...
        break;
    case 438:
        // some code for item 438...
        break;
}


it has been a while since I worked with Joomla, but I remember being able to control what was displayed on a page using the menu buttons

So when you set up a module, you can specify which links must display it and which must not.

So you can have multiple links to the same page but control what is displayed there via the links.

Sorry I'm very rusty on Joomla so I can't remember the exact terminology. Hope this helps, Cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号