Zend_Framework and Smarty, view problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BornForCode
Forum Contributor
Posts: 147
Joined: Mon Feb 11, 2008 1:56 am

Zend_Framework and Smarty, view problem

Post by BornForCode »

Hello guys,

I'm working now on a project that is made with ZF and Smarty and i have following issue: If i implement different modules in my application is easy for me to add the controllers in the front controller, but when i have to add also the view folders i saw that Smarty accepts only one folder as view.

Does anyone has found an workaround for this problem?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Zend_Framework and Smarty, view problem

Post by RobertGonzalez »

Moved to PHP - Code.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Zend_Framework and Smarty, view problem

Post by RobertGonzalez »

Can you manage view routes at all in the ZF? (I have no real experience with it so I am not sure if you can or not).
BornForCode
Forum Contributor
Posts: 147
Joined: Mon Feb 11, 2008 1:56 am

Re: Zend_Framework and Smarty, view problem

Post by BornForCode »

You can, taking from example the module name, but in this case the smarty is the problem, i wish that they implement multiple folder support for their template_dir parameter.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Zend_Framework and Smarty, view problem

Post by RobertGonzalez »

I think the template_dir can be changed prior to parsing the view. Have you tried just resetting the template_dir property before calling the display() method (or whatever methods triggers the parse)?
BornForCode
Forum Contributor
Posts: 147
Joined: Mon Feb 11, 2008 1:56 am

Re: Zend_Framework and Smarty, view problem

Post by BornForCode »

yes, you can change it in the init function from example (located in the controller) but i was looking for an embedded solution, perhaps i'm to lazy :mrgreen:
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Re: Zend_Framework and Smarty, view problem

Post by jmut »

yep, too lazy :)
In manual there is full implementation of
class Zend_View_Smarty implements Zend_View_Interface
http://framework.zend.com/manual/en/zen ... ripts.html

With little tweak you can make it work. You can then setScriptPath() on preDispatch of controller action helper ... (knowing the module, controller,action) to be executed you can easily can adjust where to look for templates
Post Reply