0

有两种方法可以编写 php 片段以将 html 放在主页上,然后将 html 放在所有其他页面上......这是针对 Joomla 3.++

<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
echo 'HTML for HOME PAGE HERE'; 
} else {
echo 'HTML for ALL OTHER PAGES HERE';
} ?>

此代码仅允许仅关注主页:

<?php
$menu = & JSite::getMenu();
if ($menu->getActive() == $menu->getDefault()) {
    echo 'HTML FOR HOME PAGE HERE';
}
?>

我想做的,特别是第二个代码片段,专注于网站上的特定页面......

原因是 A. 我不想为我正在创建的所有其他页面类型创建一个模板...... B. 我不想在我的 html 模块位置放置样式模板元素。我觉得自定义 HTML 或博客/文章帖子应该只是用于内容插入。

那么有没有办法代替调用 $menu->getDefault()) <<<< 使 getPage ???

4

2 回答 2

0

用于JInput从请求中获取页面信息。

于 2014-06-21T16:54:55.683 回答
0

找到了答案。您可以对多个页面进行直接页面编辑和 ifelse 编辑。

<?php
//This is the code for the page with menu ID 102
$menuID = JSite::getMenu()->getActive()->id ;
if ($menuID == '102')
{
echo '<strong>long</strong>';
}
?>

这是多个页面的代码。

<?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 if else for menu by ID 或 url

于 2014-06-21T17:34:53.540 回答