views in zend are not templates since zend dont support templates, so maybe you should consider integrating some template system like smarty or dwoo..
Hi all...
first of all, I'm a pretty good php coder but i'm almost new about ZF.
This is my question:
I want my app to load scripts, css, img from a folder which name is defined in some why by the user... (let's say 'template1' folder , or 'tpl2' folder or whatever). So, I want to do this in order to give the user the possibility to change the "look&feel" (template) of the whole application!
My folder structure is like the following:
-Application
-- ...
-- views
-- ...
-Library
-- ... (Zend Stuff)
-Public
-- templates
--- css
--- img
-- index.php
I've found a way to do this through setting the scripts path using the following code in my app init!
[PHP]
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelp er('viewRenderer');
// Change the path where to look for the scripts
$viewRenderer->setViewBasePathSpec(':moduleDir' . DS .'views' . DS . $this->getApplicationTemplate());
// $this->getApplicationTemplate() will return a string that is the actual template (eg. default)
[/PHP]
But, doing like this I have to create several subfolders (one for each 'template') in the view folder (that is not under the public folder) and several subfolders under a so called template folder under the public folder in order to have imgs, css, etc..
I think it would be better with all the template1 stuff in a folder...
Now, if it's clear what i want to do, what would be the best way to do this with Zend Framework.
Thanks
Marcello
views in zend are not templates since zend dont support templates, so maybe you should consider integrating some template system like smarty or dwoo..
I don't know...
You know, it's not always a bad thing to be new in something... just becouse you can see things with no constraints...
I mean... I know I can set the script folder... so i can dinamically switch between theese folder... so, even known that php is a template engine, I can have my own template system!
Please, don't misunderstand me... I'm just supposing... and, since I'm new, I'm here to heard, read and learn from you all!!
Thanks...
i agree that php is a template engine but that works only for small projects..
if you are doing some small cms, blog or something like that, and you don't have designer, etc then this approach will work..
but if its for enterprise purposes then template system is need - even zend's site use framework + smarty as template engine..
next thing: why you want to put all views in same folder?
i don't see any reason why you want to do that, and i think that framework don't support this by default.. maybe to write your own view class..
and no, you should never place any code in public accessible places..
I just wrote wrong... I don't want to put my views in the same folder... but in different folders under each "template" folder...
By the way... Smarty... I don't like it... for me it's to heavy. Performances will degrade!
Thank you for your replies... I will study and i will let you know if i find a "for me" nice, right and smart way to do what It's in my mind...
Try phptal: PHPTAL :: Template Attribute Language for PHP Smarty is too slow, zend_view, in my opinion, is good for small projects.