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条)

报告相同问题?