[cvs] [Wiki] changed: Doc/Dev/Horde_View
Chuck Hagenbuch
chuck at horde.org
Thu Feb 19 22:57:20 UTC 2009
chuck Thu, 19 Feb 2009 17:57:20 -0500
Modified page: http://wiki.horde.org/Doc/Dev/Horde_View
New Revision: 1.2
Change log: add examples
@@ -2,8 +2,67 @@
+ Horde_View
Documentation on the Horde_View package. This documentation is
adopted from the MAD documentation
(http://framework.maintainable.com/mvc/5_view.php), as many of the
Horde View ideas are also adopted from MAD, and the helpers are
directly compatible between the two systems.
+
+++ Example usage
+
+**Calling code**
+
+<code type="php">
+<?php
+
+require 'Horde/Autoloader.php';
+
+// use a model to get the data for book authors and titles.
+$data = array(
+ array(
+ 'author' => 'Hernando de Soto',
+ 'title' => 'The Mystery of Capitalism'
+ ),
+ array(
+ 'author' => 'Henry Hazlitt',
+ 'title' => 'Economics in One Lesson'
+ ),
+ array(
+ 'author' => 'Milton Friedman',
+ 'title' => 'Free to Choose'
+ )
+ );
+
+$view = new Horde_View;
+$view->books = $data;
+
+// and render a template called "template.php"
+echo $view->render('template.php');
+</code>
+
+**View template**
+
+<code type="php">
+<?php if ($this->books): ?>
+
+<!-- A table of some books. -->
+<table>
+ <tr>
+ <th>Author</th>
+ <th>Title</th>
+ </tr>
+
+<?php foreach ($this->books as $key => $val): ?>
+ <tr>
+<td><?php echo $this->escape($val['author']) ?></td>
+<td><?php echo $this->escape($val['title']) ?></td>
+ </tr>
+<?php endforeach; ?>
+
+</table>
+
+<?php else: ?>
+ <p>There are no books to display.</p>
+<?php endif; ?>
+
+</code>
++ Helpers
+++ Overview
More information about the cvs
mailing list