step 9: view for posts cakephp blog

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

  1. step 6: template setup for cakephp blog
  2. step 7: controller for posts cakephp blog
  3. step 8: making model for posts cakephp blog
  4. step 10: making view post details for cakephp blog
  5. step 11: admin view posts for cakephp blog
  6. step 12: add post view controller cakephp blog
  7. step 13: edit post view controller cakephp blog
  8. MySQL IF() Function NULL Value Example
  9. MySQL IF() Function Datetime Value Example
  10. MySQL IF() Function String Value Example

No comments:

Post a Comment

leave your comments here..