【问题标题】:Showing content on home page but not for all pages在主页上显示内容,但不是所有页面
【发布时间】:2011-02-20 20:43:04
【问题描述】:

我正在使用 cakephp 1.3,我想让我的图片幻灯片只显示在我的主页上。 我正在使用以下代码:

<?php
    if($page == 'home'){
?>
   //The content of slider here
<?php 
}else{
?>
 the message that the slider is only avaliable on homepage... or blank
<?php
 }
?>

在“家”中它工作正常,但是当我进入另一个控制器页面时,例如我的“女孩”控制器,它会显示以下消息:

Undefined variable: page [APP\views\elements\header_layout.ctp, line 38]

有人可以帮忙吗?

【问题讨论】:

    标签: php cakephp-1.3


    【解决方案1】:

    将您的初始 if() 更改为

    if (isset($page) && ($page == 'home')) {
        ...
    }
    

    这将删除警告。

    【讨论】:

      猜你喜欢
      • 2012-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-06
      • 2017-06-14
      • 2023-04-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多