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

static class can not be used in {extends file=""}?

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
dreamwing
Smarty Rookie


Joined: 17 Dec 2009
Posts: 5

PostPosted: Wed Apr 13, 2011 9:51 am    Post subject: static class can not be used in {extends file=""}? Reply with quote

{extends file="{myClass::method()}/header.tpl"} will trigger an error:
"illegal value for file attribute"

but if I use $tpl_dir = myClass::method(); and then use $dir in template
{extends file="{$tpl_dir}/header.tpl"} this is ok.

My point is now that in Smarty3 we can access static class directly in template, why not add this feature to extends syntax?

And thx for the fantastic {extends} syntax~
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Wed Apr 13, 2011 3:41 pm    Post subject: Reply with quote

As the template inheritance is processed at compile time the {extends} tag should accept only constant strings. It's a bug that it did accept the $tpl_dir variable. A change of it's value would not be detected.

If you need variable templates use the exteds resource at script level like
$smarty->display('extends:layout.tpl|myproject.tpl|mypage.tpl');
Here you can safely use a variable string.
Back to top
View user's profile Send private message
dreamwing
Smarty Rookie


Joined: 17 Dec 2009
Posts: 5

PostPosted: Sun Apr 24, 2011 6:26 am    Post subject: Reply with quote

thx for the script level resolution, althought I think it would be more convenient to use variables in {extends} tag
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 -> Smarty 3 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