|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Nitiphone Smarty n00b
Joined: 21 Oct 2020 Posts: 2
|
Posted: Wed Jan 20, 2021 2:20 pm Post subject: URL selected, insert defferent CSS and JS file |
|
|
Dear All,
I am so newbie with smarty and I need your help to guide me about smarty URL selected
as I have www.AAA/index/ and www.AAA/help/
I would like to add special text or something when user access www.AAA/help/
How can I use url selected as below
on a tpl file
{if isset($help_selected)}
Hello Help URL
{else}
Not here
{/if} |
|
Back to top |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Fri Jan 22, 2021 1:21 am Post subject: |
|
|
Smarty makes available the $_SERVER array. So, one can test for:
Code: | {if $smarty.server.REQUEST_URI|strpos:'/help/' !== false}Help.
{else}Nope.
{/if} |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri Jan 22, 2021 7:33 pm Post subject: |
|
|
I would NOT perform this in template.
Either pass the text to template as content variable or use a separate template for specific path.
Sorting through request URL is a task for routing part of your PHP code. |
|
Back to top |
|
|
|
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
|