> I'll give you an example, im currently trying to do a simple count
> function on my comments, which will be displayed on the posts page just
> after the title.
if you have setup an association between Posts and Comments, this info
should already be there, try pr ($this->Post->findAll); in your
controller to see what's there, because you should be able to jsut
count() the comments, eg:
// in posts_controller
function index ()
{
$this->Post->recursive = 1;
$posts = $this->Post->findAll ();
$this->set ('data', $posts);
}
// views/posts/index.thtml
<?php foreach ($data as $post): ?>
<h3><?php echo $post['Post']['title']; ?></h3>
<p><?php echo $post['Post']['body'] ?></p>
<p><?php echo count($post['Comment']); ?> comments</p>
<?php endforeach; ?>
hth
jon
--
jon bennett
t: +44 (0) 1225 341 039 w: http://www.jben.net/
iChat (AIM): jbendotnet Skype: jon-bennett
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---