Share on Google+Share on Google+

Zend FrameWork Part-9

Advertisement
In this tutorial we will study about Zend Framwork and we come to know that how to display pages using different components. How to combine all the components to display one page is discussed here.

Zend Framework-9:

Styling:

In this tutorial we left  the styling part of the current project for you, and you can implement the styling part as per your interest and requirement. We will create a folder add a style sheet file(style.css) in public folder css, the name can be select as per your choice.

Listing Books:

Now we will start the displaying part with the help of IndexController class, indexAction() function will display the output as tabular format.

IndexController.php

public function indexAction()

{

// action body

$this->view->title="My Books";

$this->view->headTitle($this->view->title);

$books=new Application_Model_DbTable_Books();

$this->view->books=$books->fetchAll();

}

Index.phtml

<p><a href="<?php echo $this->url(array('controller'=>'index',

'action'=>'add'));?>">Add new book</a></p>

<table>

<tr>

<th>Title</th>

<th>Author</th>

<th>Publisher</th>

<th>&nbsp;</th>

</tr>

<?php foreach($this->books as $book) : ?>

<tr>

<td><?php echo $this->escape($book->title);?></td>

<td><?php echo $this->escape($book->author);?></td>

<td><?php echo $this->escape($book->publisher);?></td>

<td>

<a href="<?php echo $this->url(array('controller'=>'index',

'action'=>'edit', 'id'=>$book->id));?>">Edit</a>

<a href="<?php echo $this->url(array('controller'=>'index',

'action'=>'delete', 'id'=>$book->id));?>">Delete</a>

</td>

</tr>

<?php endforeach; ?>

</table>

 

 

Advertisements

Advertisement

Posted on: April 19, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.