我需要在我的帖子视图功能中创建三个随机链接到其他帖子.
控制器:
$random = $this->Post->find('all', array(
'order' => 'rand()',
'limit' => 3,
'conditions' => array('Post.status' => 'ok')
));
Run Code Online (Sandbox Code Playgroud)
但我不知道,如何为此写一个foreach.
谢谢
我需要一个显示元素,根据用户是否登录 - 在CakePHP 2.0中
这不起作用
<?php
if ($this->Auth->loggedIn()
{
echo $this->element('user');
}
else
{
echo $this->element('guest');
}
?>
Run Code Online (Sandbox Code Playgroud)
谢谢