chris
chris

Reputation: 36937

Zend Framework, setting up multiple templates for the same code base

Really not sure if the title of the question suits the question overall. But here goes.

What I have currently is an existing SaaS project. That we want to roll out a new template over time. Think of how google introduces new features. Or some other sites might with "Try our new Beta Version".. type of thing. Well we want to do the same, and then we will eventually phase out the old look and feel.

With that, this application is built on top of Zend Framework, so looking through docs I can figure out how to override the template on a given controller. But what I want to basically do, is likely going to make use of the sessions. If it exists, use this template. If not, use the old one.

Is it possible to override the default template in such a fashion? Right now for example, the default loaded file, is "tops.phtml" if the session exists I'd like to load "tops_v2.phtml" for example. So it can use that as the template instead of "tops.phtml" when the session is found.

Upvotes: 1

Views: 207

Answers (2)

jrebs
jrebs

Reputation: 448

I think that layouts are the thing you probably want to use, as was briefly touched on by Richie. Based on the question, I'm guessing you aren't already using them. Ultimately you can design a layout that defines the overall website look and then each of your action templates will only then render a fragment of the page (which will be dynamically placed in the content portion of the layout).

Using whatever logic you choose, you can then assign one of any number of layouts to be used on a given page load and of course you could store this as a user preference or something.

Upvotes: 0

zavg
zavg

Reputation: 11061

Zend Framework 1.x solution:

You can disable ViewRenderer plugin in the action, and choose template manually:

public function indexAction(){
      $this->_helper->viewRenderer->setNoRender(true);
      echo $this->view->render("path/to/template/template.phtml");        
}

Upvotes: 1

Related Questions