0

我有一种情况,我希望我的两个页面看起来与其他页面不同,但它们不是首页。如果是这样,那将很容易,因为下面的代码可以解决问题。

$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';

esle(do something else)
 }
?>

简而言之,我想要一种类似的方法,但这次是通过 ID/URL 获取菜单。有任何想法吗?

4

2 回答 2

5

我得到了答案……您需要检查的是菜单 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 '';
  }
?>
于 2012-07-17T07:38:40.237 回答
1

Page ItemId 可以使用$itemid = JRequest::getInt( 'Itemid' );

于 2012-07-12T08:26:40.633 回答