View previous topic :: View next topic |
Author |
Message |
nforced Smarty n00b
Joined: 16 Feb 2016 Posts: 4
|
Posted: Tue Feb 16, 2016 4:36 pm Post subject: Relative {include} problem after upgrade |
|
|
I've been using 3.1.21-dev on one project for a long time and I decided to upgrade to what's current 3.1.29 and I ended up with the following when try to include template from with a sub-dir. Code: | Uncaught --> Smarty: Unable to load template file './list.tpl' in 'file:_master.tpl' | Here is my folder structure: Code: | tempaltes/
listing/
index.tpl
list.tpl
_master.tpl |
what has changed is with the older version I would get error in file:listing/index.tpl for example if I try to include non-exising file Code: | Uncaught --> Smarty: Unable to load template file './non_exisint_file.tpl' in 'file:listing/index.tpl' | where I now get error in file:_master.tpl and this basically is why the new version is not working for me.
Here is sample of listing/index.tpl
Code: | {extends file="_master.tpl"}
{block name="body"}
{include file="./list.tpl"}
{/block} |
I use $smarty->display("listing/index.tpl");
What has changed and how do I overcome this?
Thanks |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Feb 16, 2016 6:33 pm Post subject: |
|
|
Include files with paths relative to templates directory.
I.e. listing/list.tpl
Or, better yet, use {extends} over {include} where possible. |
|
Back to top |
|
nforced Smarty n00b
Joined: 16 Feb 2016 Posts: 4
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Feb 16, 2016 9:04 pm Post subject: |
|
|
It was a bug. |
|
Back to top |
|
nforced Smarty n00b
Joined: 16 Feb 2016 Posts: 4
|
Posted: Wed Feb 17, 2016 10:45 am Post subject: |
|
|
AnrDaemon wrote: | It was a bug. |
What do you mean by "was" like you find it and fixed it? I am talking about 3.1.29 |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Feb 17, 2016 6:24 pm Post subject: |
|
|
The way it worked was a bug. Now it is fixed, and it no longer works in the wrong way.
Look yourself at what you've posted.
You're including "./template-in-same-directory.tpl" from "listing/index.tpl", which means you want to include "listing/template-in-same-directory.tpl". Obviously, there's no such file and include is failing. |
|
Back to top |
|
nforced Smarty n00b
Joined: 16 Feb 2016 Posts: 4
|
Posted: Wed Feb 17, 2016 6:28 pm Post subject: |
|
|
I see, well this can be a bit misleading. For example when I try to include something inside listing/index.tpl same directory to me means the same directory where index.tpl is. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Wed Feb 17, 2016 6:33 pm Post subject: |
|
|
Just don't use relative paths. Ever. |
|
Back to top |
|
|