0
我只是想知道如何在CakePHP中使用$this->set()
方法來使用/定義我自己的函數?我想要做這樣的事情...
AppController.php
<?php
function checkSetup() {
if ($this->Auth->user('setup') == 'notcomplete') { return true; }
}
$this->set('isSetup', checkSetup());
?>
,然後我將能夠訪問並調用它在我的視圖文件:
<?php if ($isSetup): ?>
You haven't setup your profile yet!
<?php endif; ?>
我我已經嘗試過了,但是顯然這不起作用,因爲我得到了一個巨大的致命錯誤。有關我如何做到這一點的任何想法/建議?
感謝您的幫助,我沒有意識到它必須在一個函數。隊友的歡呼聲 ;) –