Hi all,
I am learning cakePHP 1.26.
A question came across my mind when I was creating a function in a Controller.
How do I maximize the usability of a self-defined function in CakePHP.
Here is my sample code:
function hello($id=null){
$IfLoggedIn=$this->Session->check('user');
if($IfLoggedIn){
//search the database
//$result=doing something from the search results
$this->set('userInfo',$result);
return "2";
else if(!$IfLoggedIn && $id!=null){
return "1";
}
else if($sid==null){
return "0";
}
}
and then in a .ctp file, I will make use of this function:
$u = $this->requestAction('../hello');
if($u==2){
echo "welcome back, my friend";
}
else{
echo "Hello World";
Please advise.