« Return to Thread: Controller and View Question

RE: Controller and View Question

by Xavier Vidal :: Rate this Message:

Reply to Author | View in Thread

Hi

We're using some different "views" to get a useful layout for each purpose.

We start using:

- portal-layout.php
- clean-layout.php

The first one has the header, footer, top menu, the main content and
optionally the left and right menus.
The clean layout only has the header and footer.

So, in our scripts we can do the following (extending the Zend_View
component):

$view = new TemplateView();
$view->tplMain  = 'articles/view.php';
$view->tplLeft  = 'articles/leftMenu.php';
$view->tplRight = 'articles/contextual.php';
$view->articles = $oArticles->get();
$view->render('portal-layout.php');

The "portal-layout.php" is constructed this way:

$this->render('header.php');
$this->render('topMenu.php');
if(isset($this->tplLeft))
    $this->render($this->tplLeft);
$this->render($this->tplMain);
if(isset($this->tplRight))
    $this->render($this->tplRight);
$this->render('footer.php');

More or less...

Xavier Vidal Piera
Enginyer Tècnic d'Informàtica de Gestió
Tècnic Especialista en Informàtica de Sistemes
xavividal@...
610 68 41 78
http://www.webpersonal.net/redness
http://www.myspace.com/xaviervidalmusic
 

> -----Mensaje original-----
> De: Ian Warner [mailto:iwarner@...]
> Enviado el: domingo, 25 de marzo de 2007 18:08
> Para: Ralph Schindler
> CC: Zend Framework General
> Asunto: Re: [fw-general] Controller and View Question
>
> Ralph Schindler wrote:
> > Hey group,
> >   I am curious how everyone implements common headers and footers
> > within a given application.  As I see it there are two methods:
> >
> > a) include the header and footer in each view script via the
> > $this->render(..) routine.
>
> I simply within the main site view call in the following files:
>
>   <?php echo $this->render('../themes/' . $this->theme_template .
> '/html/html_head.inc.php') ?>
>
>   echo $this->render($this->actionTemplate);
>
> This allows the view to specify the template and the template
> elements are called via the theme.
>
> >
> > b) use Zend_Controller Plugins to write to the view a
> standard header
> > and footer to the view body at preDispatch() postDispatch() /
> > preRouteStartup / postRouteStartup times.
> >
> > Both methods have their pros and cons..
> >
> > In method a) you are required to handle it in every script,
> which can
> > be tedious.  But it allows you flexibility to not include
> the common
> > header and footer blanketly on all requests when it makes
> sense not to include it.
> >
> > Method b) writes headers and footers on all requests, unless I am
> > missing something.  The benefit is that you can write specific
> > controller/action scripts and they can be completely
> autonomous from
> > the rest of the application.
> >
> > I like method b), but I wonder:  Are there ways to inject (or
> > callback) to write specific controller/action needed headers to the
> > common header, for example, adding a page specific JS script to a
> > pages <head>.  Are there ways that a specific controller/action can
> > choose not to use a header/footer dispatched previously?
> >
> > Looking for best practices / ideas here..
> >
> > Thanks,
> > Ralph
> >
> >
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.446 / Virus Database: 268.18.17/732 - Release
> Date: 24/03/2007 16:36
>  
>

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 268.18.17/732 - Release Date: 24/03/2007
16:36
 

 « Return to Thread: Controller and View Question