Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to include tpl with relative path #16

Open
SaNaSaGa opened this issue Apr 8, 2015 · 1 comment
Open

How to include tpl with relative path #16

SaNaSaGa opened this issue Apr 8, 2015 · 1 comment

Comments

@SaNaSaGa
Copy link

SaNaSaGa commented Apr 8, 2015

I can't include tpl file with relative path.

{include file="/common/header.tpl"}
{include file="/common/input.tpl"}

When I do this I got error message.

Smarty: Unable to load template file '/common/header.tpl' in '/var/www/webapp/test/module/Application/view/application/index/detail.tpl' <-- thrown in /var/opt/webapp/dom_rsv/vendor/SmartyModule/vendor/smarty/libs/sysplugins/smarty_internal_templatebase.php on line 130

@maglnet
Copy link

maglnet commented Apr 29, 2015

Hi,

I'm not sure, if this really is the same problem like yours, but I had trouble with relative includes, too.
I think one problem is that the template directory will be set to the current templates path.
e.g. if you render the template /index/detail.tpl the template path will be set to /index and then the relative path will result in being /index/common/header.tpl, which is not correct.

The template directory is set here:
https://github.com/MurgaNikolay/SmartyModule/blob/425dc4cec3c10aa6bfce135628934cad3f8e3415/src/SmartyModule/View/Renderer/SmartyRenderer.php#L143

imho it should not set the template dir, but add all paths from the template path stack so Smarty can check all registered paths.
I will have my hands on this today and create a branch in my fork, perhaps you could check if my adjustment would fix your problem, too.

best regards
Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants