MrAnchovy / Kohana_Smarty3

Integration of Smarty v3 with the Kohana PHP Framework
25 stars 13 forks source link

unable to use smarty {extends} #6

Closed prakash closed 12 years ago

prakash commented 12 years ago

while using {extends} tags on tpl file I am getting an exception error

MrAnchovy commented 12 years ago

Are all your template files in APPPATH.views? If they are in a module's views directory there seems to me some inconsistency as to whether it works or not (and it shouldn't work at all!). For now, is putting all the view files in directories off APPPATH.views an acceptable workaround? Or you could bypass Kohana views altogether, get hold of a Smarty object with View::smarty() and use absolute paths? Global view variables should still be visible.

But I will fix it some day...

prakash commented 12 years ago

yes below is my application views structure

application/views/
    - default
        - layouts
            - core.tpl
        - index.tpl

in core.tpl I have following code as a placeholder

{block name="content"}{/block}

and in index.tpl

{extends file="layouts/core.tpl"}

{block name="content"}
    if you can view it, then it's working :)
{/block}

and finally, the error:

MrAnchovy commented 12 years ago

I think you want

{extends file="default/layouts/core.tpl"}

because include/extends paths are relative to the (array of) paths in $_template_path, not relative to the current template.

I have just pushed a fix that correctly adds the module paths so {include}d and {extend}ed templates should be found in any views directory (as long as you have the path within the directory correct! :D

prakash commented 12 years ago

so is this fix in addition with supporting latest smarty version included on master?

MrAnchovy commented 12 years ago

Yes it is, and tagged 0.9.4