我正在使用 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
}
?>
在“主页”中它工作正常,但是当我转到其他 Controller 页面(例如我的“女孩” Controller )时,它会显示此消息:
Undefined variable: page [APP\views\elements\header_layout.ctp, line 38]
有人可以帮忙吗?
最佳答案
将您的初始 if() 更改为
if (isset($page) && ($page == 'home')) {
...
}
这将删除警告。
关于php - 在主页上显示内容但不是在所有页面上显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5059879/