Monday, October 31, 2011

Why specify the controller in the view?

I just noticed this in the cakephp book.  In the first example, you have the following line(s) in index.ctp:

http://book.cakephp.org/view/1536/Creating-Post-Views

<?php echo $this->Html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id'])); ?> <--- this is the first example of a view

http://book.cakephp.org/view/1540/Editing-Posts

<?php echo $this->Html->link($post['Post']['title'], array('action' => 'view', $post['Post']['id']));?>  <--- this is a later example, when you're editing the post.

The question is about this line: 'controller' => 'posts' <--- this doesn't seem to affect the way info is posted.  index.ctp is already tied to the index method in the PostsController, so what role does this play?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: