CakePHP Smarty View with theming support (i.e. Themed Smarty View)
I use Smarty View, but want to benefit from theme options. Since for theming cake use Theme View, I cant use both Smarty and Theme at the same time. Perhaps can combine the code but am not that familar with View eingine core. Already have a lot v开发者_StackOverflowiews done with smarty and do not want to recreate all of them with plain php. Is there a ready combined solution i.e. Themed Smarty View?
Thanks
For stuff like this I always created different layouts. Then I would switch the layout in my app_controller.php
function beforeFilter(){
// If you are in the cms then use the cms layout instead
if(isset($this->params['cms'])){
$this->layout = 'cms';
}
}
Then you can create your layouts in your app/views/cms.ctp
. This way you can just swap out the layout as you need, which will change the whole site surround.
Having never tried to use Smarty within a CakePHP application, I'm not sure if there is a combined theme and smarty solution. You could try creating your own CakePHP component which would prepare the data in the controller and render it out to the view. Although I can't really see much point to using Smarty within CakePHP, as it already has a complete MVC stack, with views.
精彩评论