Joe*_*the 0 php url joomla if-statement
我有一种情况,我希望我的两个页面与其余页面看起来不同,但它们不是首页。如果是这样,那么很容易,因为下面的代码可以解决问题。
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
esle(do something else)
}
?>
Run Code Online (Sandbox Code Playgroud)
简而言之,我想要一种类似的方法,但是这次,通过ID / URL获取菜单。有任何想法吗?
我得到了答案...所有您需要检查的是菜单ID,然后将代码放在下面。
<?php
//This is the code for the page with menu ID 6
$menuID = JSite::getMenu()->getActive()->id ;
if ($menuID == '6')
{
echo '';
}
elseif ($menuID == '2') //This is the HTML for page with menu ID 2
{
echo '';
}
elseif ($menuID == '4') //THis is the html for page with menu id 4
{
echo '';
}
else //This is the HTML code for the rest of the pages
{
echo '';
}
?>
Run Code Online (Sandbox Code Playgroud)