i am newbie in cakephp ..actually i have two problems .. first one is I am setting variables in AppController in order to use them in default.ctp.
public function beforeRender(){
$id = $this->Auth->user('idUser');
$this->loadModel('Userinfo');
$data= $this->Userinfo->find('all',array(
'conditions' => array('Userinfo.User_id' => $id)
));
foreach($data as $d){
$product_purchase = $d['Userinfo']['product_purchase'];
}
$this->set('userinfo',$product_purchase);
}
so it is working fine when i use the variable into my default.ctp layout .. but the problem is when i logout from the the app then it displays this error on my login page
Undefined variable: product_purchase
What am I doing wrong? by the way i want to mention here is that in my login page i am not using default.ctp well which i think it has nothing to do with dat
the second problem is i want to show specific menu items for the specific user ... so i am doing this in my view page
<?php if ($userinfo == 1){ ?>
<li><a href="explorer.html" class="shortcut-medias" title="Media">Media</a> </li>
<?php }else{ //nothing }?>
value in userinfo is 2 .. but if else isnt working .. it is still displaying the menu