I’m just wondering how I can use/define my own function using the $this->set() method in CakePHP? I want to do something like this…
AppController.php
<?php
function checkSetup() {
if ($this->Auth->user('setup') == 'notcomplete') { return true; }
}
$this->set('isSetup', checkSetup());
?>
And then I will be able to access and call it in my view file:
<?php if ($isSetup): ?>
You haven't setup your profile yet!
<?php endif; ?>
I’ve tried that, but It clearly doesn’t work as I get a massive fatal error. Any ideas/suggestions on how I can do this?
That line needs to be inside some function in order to be called. Presumably you want it in the beforFilter of your app controller – something like this: