如何在智能模板中从 URL 访问变量值


How to access the variable values from URL in smarty template?

我正在使用PHP和smarty为我的网站。我在地址栏中获得一个 URL,我想将 URL 中的值用于 smaarty 模板。那么有可能做到这一点吗?如果是,你能解释一下吗?为了您的理解,我为您提供如下URL:

http://localhost/eprime/entprm/web/control/modules/enquiries/manage_contact_us.php?contact_id=56&contact_full_name=ZainabJuzerBhavnagarwala&contact_email_id=fatemabhav21@gmail.com&op=view&reply_to_enquiry_suc=1&from_date=11/09/2000&to_date=11/09/2013

假设从上面的 URL 中,我想访问contact_full_namecontact_email_id的变量值,该模板目前正在被取消。你能解释一下我如何做到这一点吗?

实际上我尝试了以下代码,但它没有输出任何内容。

<input type="text" name="contact_full_name" id="contact_full_name" value="{ if $data.contact_full_name!=''} {$data.contact_full_name|capitalize} {else} {$contact_full_name|capitalize} {/if}" class="">

提前谢谢。

看看聪明的保留变量:

{$smarty.get.contact_email_id}

看看聪明的保留变量:

{$smarty.get.contact_email_id}

由于 Smarty 将输出变量的内容,如果存在,则没有任何内容,那么您应该只是:-

<input type="text" name="contact_full_name" id="contact_full_name" value="{$smarty.get.contact_full_name|capitalize}" class="" />

(任何人都可以复制和粘贴LOL)

根据之前的答案:

$smarty->debugging_ctrl='URL';添加到 PHP 脚本并&SMARTY_DEBUG添加到 URL 将弹出分配的变量(但不会 get 和 post)