Joomla,如果其他用于按ID或URL进行菜单 [英] Joomla if else for menu by ID or url

查看:97
本文介绍了Joomla,如果其他用于按ID或URL进行菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a situation whereby i want two of my pages to look different form the rest but they are not front pages. If they were it would be easy as the code below would do the trick.

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

esle(do something else)
 }
?>

简而言之,我希望采用类似的方法,但是这次,要通过ID/URL获取菜单.有什么想法吗?

In short i want a similar approach but this time, to get the menu by ID/URL. Any ideas?

推荐答案

我得到了答案...所有您需要检查的是菜单ID,然后将代码放在下面.

I got the answer to this...all you need to check is the menu ID then put the code below.

<?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 '';
  }
?>

这篇关于Joomla,如果其他用于按ID或URL进行菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆