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

Show a piece of code only in a specific template

 
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
StratoKyke
Smarty Rookie


Joined: 30 Apr 2015
Posts: 9

PostPosted: Wed Jul 29, 2015 4:22 pm    Post subject: Show a piece of code only in a specific template Reply with quote

I'll explain my problem:

This is my template:

Code:

{include file="header.tpl" title="" page_description="" page_keywords=""}
{include file="leftSide.tpl"}

code of template
{include file="rightSide.tpl"}
{include file="footer.tpl"}


I Wish I could add a piece of code in the template: leftSide.tpl visible only when I open this template.


How could I do? Smile
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Jul 29, 2015 10:31 pm    Post subject: Reply with quote

Go from opposite side. Use template extension, not template inheritance.
Also check http://www.smarty.net/forums/viewtopic.php?t=25486 for one more example.
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 30, 2015 12:34 am    Post subject: Reply with quote

AnrDaemon wrote:
Go from opposite side. Use template extension, not template inheritance.
Also check http://www.smarty.net/forums/viewtopic.php?t=25486 for one more example.
Again you missed the point!!!!


You can pass a flag when calling leftSide.tpl
Code:
{include file="leftSide.tpl" foo=true}


In lestSide.tpl
Code:
{if isset($foo)}
...
{/if}
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jul 30, 2015 9:54 am    Post subject: Reply with quote

I'm not missing the point, I'm offering a viable and transparent alternative.
If I only need a specific code added to template, I would NOT pile cases upon cases, which someone after my death would need to track down and replace one by one.
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 30, 2015 2:15 pm    Post subject: Reply with quote

AnrDaemon wrote:
Go from opposite side. Use template extension, not template inheritance.

What does that mean. He does not use template inheritance at all. The {extends} tag does define parent child relation in template inheritance and is no different a different method.

I can't see how this can solve his problem that he needs to know in a subtemplate if it was called from from a certain main templem at all.
Back to top
View user's profile Send private message
StratoKyke
Smarty Rookie


Joined: 30 Apr 2015
Posts: 9

PostPosted: Thu Jul 30, 2015 2:30 pm    Post subject: Reply with quote

Thank you so much U.Tews Smile I solved the problem.
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