1 to 4 of 4
If a publisher has many books..
class Book extends ActiveRecord
{
var $belongs_to = array('author', 'publisher');
}
class Publisher extends ActiveRecord
{
var $has_many = array('books');
}
Now to display book's publisher..
class BookController extends ApplicationController
{
var $models = 'book, author, publisher';
function show()
{
$this->Book = $this->Book->find(@$this->params['id'], array('include' => array('author', 'publisher') ));
}
}
And as usual
{Book.publisher.name?}
Or if you found an publisher and included it's books..
{?Publisher.books}
{loop Publisher.books}
<p>{Book.name}</p>
{end}
{end}
Didn't tested, but should work fine.
Flancer, ticket 64 is a proposal a contributor made to improve the booklink tutorial that has not been approved yet and that might have errors, please feel free to correct the proposal with your findings on that same ticket so we can add a valid example instead of a bogus one.
1 to 4 of 4