我对TinyButStrong有点新意,我想知道如何检查布尔变量是0还是1?例如,我有这个:
$TBS->MergeBlock('tests', $tests);
Run Code Online (Sandbox Code Playgroud)
并且$ tests有一个变量调用'activated',这是一个布尔值.因此,在我的.docx文档中,如果变量设置为true(1),我想写字符串'Activated',如果设置为false(0),我想写'non-activated'.
我应该在.docx文档中使用哪种语法?
提前致谢.
我想知道如何在cakePHP中使用一个函数,当我加载页面时它总是被调用?
使用此示例更精确:
我有我的主页:index.ctp我有另一页:profil.ctp
我想要的是,当我尝试访问profil.ctp时,如果我没有登录,它会自动将我重定向到index.ctp页面.
我已经做了什么:
UsersController:
function index() {
if (!empty($this->data))
$this->Session->write(array('User' => array('connected' => true)));
}
Run Code Online (Sandbox Code Playgroud)
ProfilsController:
function index() {
if (!$this->Session->read('connected'))
$this->redirect(array('controller' => 'users', 'action' => 'index'));
}
Run Code Online (Sandbox Code Playgroud)
问题是我不想将这个代码添加到每个页面,以及我所有控制器的每个功能.
有任何想法吗 ?
问候.