Shouldnt the action be in Categories Controller, not in Posts ?
And why not use just:
$this->Category->findAll('Category.title
ASC', $num);
On 31 tammi, 20:18, Neil <[EMAIL PROTECTED]> wrote:
> Hello, I have spent the morning figuring out how to display a list of
> blog categories on every page of my site. I think my logic is correct
> but I am applying it wrong. I have a posts table that has a $belongsTo
> relations ship with my category table.
>
> My Model:
> class Post extends AppModel {
>
> var $name = 'post';
> var $belongsTo = array ('Category' => array(
> 'className' => 'Category',
> 'foreignKey'=>'category_id')
> );
>
> }
>
> In My Post Controler:
> function getcats($num = 5)
> {
> $getcats = $this->Post->Category->findAll('Category.title
> ASC', $num);
>
> if (isset($this->params['requested']))
> {
> return $getcats;
> }
> $this->set('getcats', $getcats);
> }
>
> In my view_cat Element:
> <?php
> $getcats = $this->requestAction('/catagories/getcats/5');
> ?>
>
> <?php foreach ($getcats as $categories): ?>
>
> <?php echo($categories['Category']['title']);?>,
>
> <?php endforeach; ?>
>
> in my layout:
> <?php echo $this->renderElement('view_cat'); ?>
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---