Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Potential bug: extending template files with same name

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
erstaunlich
Smarty n00b


Joined: 29 May 2014
Posts: 2

PostPosted: Thu May 29, 2014 11:46 pm    Post subject: Potential bug: extending template files with same name Reply with quote

I've submitted this to the google bug list too (here). My appologies if I shouldn't be double posting this, please feel free to remove if I've done this in error.

I seem to be having an issue with the compilation of template files having the same name but in different directories. I'm using the extends: resource type.

I have a folder structure something like this:

/core/templates/layout.tpl
/core/admin/templates/index.tpl
/app1/templates/index.tpl
/app1/sub_app/templates/index.tpl
/app2/templates/index.tpl

There's a "core" with multiple applications in other folders and subapplications can be under core and those applications. Each app/subapp has its own templates/ dir and they all extend on layout.tpl in the core dir. Each app/subapp sets the smarty templateDir to its own templates subfolder.

Templates are being compiled into:
/core/smarty/template_c/

My call to render a page is:
$this->display("extends:/core/templates/layout.tpl|{$page}.tpl");

When using force compile, it works as expected. Without, all those index.tpl files get compiled to the same filename in templates_c/ and it will render whichever one is already saved.

I've read that Smarty v3 that should also take into account the dir of the tpl when building its cache id, so this isn't the behaviour I'm expecting.

I'm running 3.1.17 and seeing the same issue on Windows and Linux.

Appreciate any help
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Sat May 31, 2014 10:26 pm    Post subject: Reply with quote

Read the 3.1.16 Release Notes.

If you use interitance with variable file names you must set
$smarty->inheritance_merge_compiled_includes = false;
Back to top
View user's profile Send private message
erstaunlich
Smarty n00b


Joined: 29 May 2014
Posts: 2

PostPosted: Sun Jun 01, 2014 2:43 am    Post subject: Reply with quote

Hi Uwe, thanks for the suggestion. This didn't resolve the problem, unfortunately.

It would still take whichever index.tpl is already compiled in the template_c/ folder instead of being aware of the path of the index.tpl file, which is different for each.

I think this arises since I'm using relative directories when setting the template dir - the smarty compile id doesn't take into account the full path of the template file, rather only the relative path (which is ./templates/index.tpl for each of these different apps/subapps.

I've managed to work around this by only passing directories by their full/absolute path to set/addTemplateDir(), instead of a path relative to the currently running script.

Should the compile id for a template take into account its absolute path, instead of just its relative path?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Jun 02, 2014 8:16 pm    Post subject: Reply with quote

The bugfix is now in the SVN trunk and will later be included in 3.1.19
Back to top
View user's profile Send private message
Lenchik
Smarty n00b


Joined: 13 Nov 2010
Posts: 4

PostPosted: Thu Jul 03, 2014 10:22 pm    Post subject: Reply with quote

I am not sure if this bugfix caused another bug, but something is wrong with 3.1.19.

There is index.php
in the same folder there are sitecontent/ with subfolders and template_c/.
There are
sitecontent/index.tpl
sitecontent/ic/index.tpl
sitecontent/create/index.tpl
and like.
Index.php calls like $smarty->display('extends:some_parent.tpl|'.$currentworking);
It shows only firstly viewed index.tpl even when supposed to show index.tpl from other path.
$smarty->force_compile = true; make all work as before.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Thu Jul 03, 2014 11:21 pm    Post subject: Reply with quote

Yep, you are right. The fix created another problem.

It's now fixed in the SVN trunk.
The fix will later be included in 3.1.20
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP