Display content on the main page, but not for all pages.

I am using cakephp 1.3 and I want my image slide to only display on my home page. I am using the following code:

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

In the "home" mode, it works fine, but when I go to another page of the controller, such as my controller "girls", it displays this message:

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

can anyone help here?

+3
source share
1 answer

Change the initial value of if () to

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

This will clear the warning.

+1
source

Source: https://habr.com/ru/post/1793443/


All Articles