Guest User

Untitled

a guest
Apr 25th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. // controller
  2.  
  3. public function index()
  4. {
  5. $this->template->content = new View('pages/home');
  6. $this->template->content->content_showmany = new View('pages/contact_showmany');
  7.  
  8. $this->template->content->content_showmany->contacts =
  9. ORM::factory('contact')
  10. ->select('id', 'firstname', 'lastname')
  11. ->orderby('firstname', 'ASC')
  12. ->find_all();
  13. }
  14.  
  15. // pages/home
  16.  
  17. <h3>View all your contacts</h3>
  18.  
  19. <p><?php echo html::anchor('contact/add', 'Add a contact') ?></p>
  20.  
  21. <?php echo $content_showmany ?>
  22.  
  23. // pages/contact_showmany
  24.  
  25. <table>
  26. <tr>
  27. <th>First</th>
  28. <th>Last</th>
  29. <th>Link</th>
  30. </tr>
  31. <?php foreach ($contacts as $contact): ?>
  32. <tr>
  33. <td><?php echo html::anchor('contact/view/'.$contact->id, html::specialchars($contact->firstname)) ?></td>
  34. <td><?php echo html::specialchars($contact->lastname) ?></td>
  35.  
  36. </tr>
  37. <?php endforeach ?>
  38. </table>
Add Comment
Please, Sign In to add comment