If you are only ever going to filter for category_id, you could do this:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 3));

Then change you index function to:

function index($category_id = null)

...and then check for a non null value later in your code when you do your data 
extraction.

Jeremy Burns
[email protected]
(Skype) +44 208 123 3822 (jeremy_burns)
(m) +44 7973 481949
(h) +44 208 530 7573

On 14 Jan 2010, at 10:47, nyahoo wrote:

> Hi All,
> 
> I hope someone can help me with what I think is a simple question that
> I just haven't wrapped my head round yet. (I'm new to CakePHP).
> 
> I want to create a link that requests the index action of my blog
> (which is paginated), but at the same time passes it a condition, like
> category_id=2 or something like that, so that I can have a list of
> categories to the right of my blog index that reloads the page with
> just that categories blogs. This seems like a straightforward idea to
> me, but I don't seem to be able to get the syntax right. I can do
> limits and orders but not conditions. Can anyone help me please?
> 
> Some examples:
> 
> This works:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 'limit'=>2));
> 
> This doesn't work:
> $html->link($category_name,array('controller'=>'Blogs',
> 'action'=>'index', 'conditions'=>'Blog.category_id=3'));
> 
> My controller code:
> function index() {
>       $this->Blog->recursive = 0;
>       $this->set('blogs', $this->paginate());
> }
> 
> Thanks for any advice in advance!
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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

Reply via email to