Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/05/2011, 13:01
Avatar de pateketrueke
pateketrueke
Modernizr
 
Fecha de Ingreso: abril-2008
Ubicación: Mexihco-Tenochtitlan
Mensajes: 26.399
Antigüedad: 16 años
Puntos: 2534
Respuesta: Aporte: Class para el uso de plantillas

Me agrada, simple y bien escrito.

Ejemplo:
Código PHP:
$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'
    
)
);

$tpl = new Khaus_View_Template('books.phtml');
$tpl->view->books $data;

echo 
$tpl->render(); 
books.phtml
Código PHP:
    <?php    if ($this->books) { ?>
     
        <table>
            <tr>
                <th>Autor</th>
                <th>Titulo</th>
            </tr>
     
            <?php foreach ($this->books as $key => $val) { ?>
            <tr>
                <td><?php echo htmlentities($val['author']) ?></td>
                <td><?php echo htmlentities($val['title']) ?></td>
            </tr>
            <?php ?>
     
        </table>
     
    <?php } else { ?>
     
        <p>No hay libros que mostrar.</p>
     
    <?php ?>
__________________
Y U NO RTFM? щ(ºдºщ)

No atiendo por MP nada que no sea personal.

Última edición por pateketrueke; 27/05/2011 a las 13:16 Razón: ejemplo