View Single Post
  #5 (permalink)  
Old 03-28-2007, 03:15 AM
SpotSec's Avatar
SpotSec SpotSec is offline
Senior Member
 
Join Date: Feb 2007
Location: United States
Posts: 121
Default

Quote:
Originally Posted by quannm0410l View Post
Can you give me a example? I want to display a loop values in views. Thank you
Which part would you like an example of? And what is a "loop values", I assume you are talking about array values generated from a loop statement such as foreach().

In this case you would just send the array to the view object and parse through it with Zend_View or your own template system.

Here is the Zend_View example taken from the manual.
PHP Code:
<?php // Controller script
// 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'
    
)
);

// now assign the book data to a Zend_View instance
Zend_Loader::loadClass('Zend_View');
$view = new Zend_View();
$view->books $data;

// and render a view script called "booklist.php"
echo $view->render('booklist.php');
?>
PHP Code:
<?php // View script (booklist.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; ?>
I feel like this isn't what you where looking for . In that case sorry for the misunderstanding, could you rephrase your question?
__________________
Zym Framework - A Zend Framework extension library w/ demo app

SpotSec Blog:
http://spotsec.com/blog

Last edited by SpotSec : 03-28-2007 at 03:19 AM.
Reply With Quote