I get the following error:
Warning: Invalid argument supplied for foreach() in
T:\ns\cake_1.1.5.3148\app\views\elements\recentposts.thtml on line 3
/views/pages/home.thtml
...
<?php echo $this->renderElement('recentposts') ?>
...
/views/elemets/recentposts.thtml
<?php
$data = $this->requestAction('posts/recentposts');
foreach($data as $post): ?>
<div class="itemtitle">
<?php echo $html->link($Post['Post']['title'],
"/posts/view/{$Post['Post']['id']}")?>
</div>
<div class="itembody">
<?php echo $Post['Post']['body']?>
</div>
<?php endforeach;?>
/controllers/post_controller.php
<?php
class PostsController extends AppController
{
var $name = 'Posts';
function index() {
$this->Post->recursive = 0;
$this->set('posts', $this->Post->findAll());
}
function recentposts() {
//return $this->Post->findAll('','','created DESC',3);
$this->set('data', $this->Post->findAll('','','post.created
DESC',3));
}
}
?>
As you can see in the commented out section of the controller I have
attempted different things, but continue to get similar types of
errors. Im sure this is something silly I am missing. I have been
trying to use this
http://wiki.cakephp.org/docs:controller:requestaction what did I miss
or is there a better example to try and follow?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---