donglian5309 2013-04-24 06:15
浏览 265
已采纳

如何在smarty模板中访问URL的值?

I'm newbie in smarty so facing so much difficulties in using it. I've got the following URL :

http://localhost/schooling_needs/sneeds1.0/web/control/modules/chapter_youtube_videos/chapter_youtube_videos.php?chapter_id=102

I want to assign the value of chapter_id to a text field in smarty template. For that I wrote following code, but it's not getting the correct value.

<input type="text" name="chapter_id" id="chapter_id" value="{$chapter_id}">

The text field is not getting any value. Would you please help me by telling how should I assign the value of chapter_id to the above textfield? Thanks in Advance.

  • 写回答

3条回答 默认 最新

  • duanjiao4763 2013-04-24 06:20
    关注

    You need to assign it within your code to the smarty template you are using. For example:

    $smarty->assign('chapter_id', $_GET['chapter_id']);
    

    before you fetch/display your template. ^^

    Due to OP's limitations, using the built-in smarty instead of assigning to page individually.:

    {$smarty.get.chapter_id}
    

    would provide it directly from the $_GET array.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容