Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用<--{if$smarty.get";在tpl文件上获取url上的一些单词_Url_If Statement_Smarty - Fatal编程技术网

如何使用<--{if$smarty.get";在tpl文件上获取url上的一些单词

如何使用<--{if$smarty.get";在tpl文件上获取url上的一些单词,url,if-statement,smarty,Url,If Statement,Smarty,在一个tpl文件(header.tpl)上,我想写一个代码来更改按钮(每个按钮包含不同的链接),这将取决于几个不同的url设置 example.com/usa.php example.com/uk.php example.com header.tpl <!--▼HEADER--> <!--{if $smarty.get.page == "usa"}--> <a href="<!--{$smarty.const.HTTPS_URL}-->baseball

在一个tpl文件(header.tpl)上,我想写一个代码来更改按钮(每个按钮包含不同的链接),这将取决于几个不同的url设置

example.com/usa.php
example.com/uk.php
example.com

header.tpl
<!--▼HEADER-->
<!--{if $smarty.get.page == "usa"}-->
<a href="<!--{$smarty.const.HTTPS_URL}-->baseball.php" ><img src="baseball_button" ></a>

<!--{else}--><!--{if $smarty.get.page == "uk"}-->
<a href="<!--{$smarty.const.HTTPS_URL}-->soccer.php" ><img src="soccer_button" ></a>
<!--{else}--> 
<a href="<!--{$smarty.const.HTTPS_URL}-->sumo.php" ><img src="sumo_button" ></a>
<!--{/if}-->
<!--{/if}-->
<!--▲HEADER-->
example.com/usa.php
example.com/uk.php
example.com
header.tpl
有人能告诉我做上述事情的正确方法吗


关于上述内容,如果部件不工作,则始终显示底部按钮,即sumo_按钮。

您是否有任何重写将
usa.php
解释为
index.php?page=usa
?在您的代码中,您正在检查get中的
page
参数,但您提供的URL没有任何参数。谢谢您的评论。因为我希望url尽可能简单,所以我不使用任何参数,如您向我展示的,“xxxxx.com/usa.php”是我已经确定的url,在这种情况下,我想知道是否有任何代码可以拾取或读取一些单词,如“usa”用我在上面尝试过的方法,而不是使用参数从url。你知道这方面的情况吗?