| 1 |
Seems like the author has been saved but it its not included on the `app/views/book/show.tpl` view. You'll add it this code right after `<? $content_columns = array_keys($Book->getContentColumns()); ?>` |
|---|
| 2 |
|
|---|
| 3 |
<label>_{Author}:</label> <span class="static">{book.author.name?}</span><br /> |
|---|
| 4 |
|
|---|
| 5 |
The final step - show the author in the listing. In order to do it replace the last string of the listing method in book_controller.php with the following text: |
|---|
| 6 |
|
|---|
| 7 |
$this->books =& $this->Book->find('all', array_merge(array('include' => 'author'), $this->pagination_helper->getFindOptions($this->Book))); |
|---|
| 8 |
|
|---|
| 9 |
Now we can edit `app/views/book/listing.tpl`: |
|---|
| 10 |
* insert new string `<th>_{Author}</th>` right before `<?php $content_columns = array_keys($Book->getContentColumns()); ?>` |
|---|
| 11 |
* Make the template to output author'a name by adding `<td>{post.user.login?}</td>` after `<tr {?post_odd_position}class="odd"{end}>` |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
You must be screaming now about the rare `_{Author}` and `{book.author.name?}` syntax. Thats actually [Sintags](http://www.bermi.org/projects/sintags) a small set of rules that helps on writing cleaner views and that will be compiled to standard PHP. |
|---|