step 9: making view for posts cakephp blog
fire-up your favorite browser to see the effect before creating posts view "http://localhost/cakeblog/posts" in cakephp blog. Your Browser output should look like as follows:
To solve the view problem, make a file “/app/views/posts/index.ctp" then copy & paste blow code into the file.
/app/views/posts/index.ctp
<!-- File: /app/views/posts/index.ctp -->
<h1>Blog Posts</h1>
<table>
<tr>
<th>Id</th>
<th>Title</th>
</tr>
<?php foreach ($posts as $post): ?>
<tr>
<td><?php echo $post['Post']['id']; ?></td>
<td>
<?php echo $html->link($post['Post']['title'], array('action' => 'view',$post['Post']['id']));?>
</td>
</tr>
<?php endforeach; ?>
</table>
Now browser again and see the effect. Your browser's output should look like as follows:
Related Tutorial Examples
- step 6: template setup for cakephp blog
- step 7: controller for posts cakephp blog
- step 8: making model for posts cakephp blog
- step 10: making view post details for cakephp blog
- step 11: admin view posts for cakephp blog
- step 12: add post view controller cakephp blog
- step 13: edit post view controller cakephp blog
- MySQL IF() Function NULL Value Example
- MySQL IF() Function Datetime Value Example
- MySQL IF() Function String Value Example


No comments:
Post a Comment
leave your comments here..