Php – How to access value from URL in smarty template

PHPsmarty

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.

Best Answer

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.

Related Topic