namesco / ZTal

ZTal makes integrating the PHP templating system PHPTAL into Zend Framework easy.
Other
21 stars 3 forks source link

Do not hardcode file extensions and template paths #4

Closed sir-gawain closed 13 years ago

sir-gawain commented 13 years ago

in dispatchLoopStartup() of the action plugin you should not hardcode the file extensions. i use .html instead of .xhtml so i have to modify your code. Same thing with _currentModuleTemplatePaths(). I use "templates/" instead of "scripts/" because i see the xhtml files not as scripts... i again have to hack your code. would be nice to have two options for this (or do not set them at all, this can be set up while bootstrapping).

far-blue commented 13 years ago

I have refactored the original ztal path code to make much better use of the existing Zend_View and ViewRenderer facilities. The normal Zend functionality for manipulating the locations and names of templates should now apply correctly to the PHPTAL template paths (e.g. setScriptViewPathSpec). I've also adjusted the suffix code to only override the default 'phtml' suffix but leave custom suffixes alone. these modifications are currently on the dev branch - please test them and let me know your thoughts :)

sir-gawain commented 13 years ago

Works so far for me at least the part with the suffixes. Unfortunately the path to "scripts/" is hardcoded into ZF and cannot easily changed. Or i couldn't find an easy method... i use a postDispatch() hook now to add the current module directory with "templates/" instead of "scripts/" directly into the view.

far-blue commented 13 years ago

It should be possible to use the Zend_View setScriptPath method to force an override of the standard scripts folder path and the Zend_Controller_Action_Helper_ViewRenderer setViewScriptPathSpec to change the controller/action.suffix format for the script locations within the scripts folder :) The hard-coding of the scripts and helpers sub-paths within the views folder is a bit of a shame though. Ztal sticks with them because they are the Zend standard layout and it is not Ztal's role to start changing such conventions :)