|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
unidude Smarty n00b
Joined: 27 Jun 2005 Posts: 2
|
Posted: Mon Jun 27, 2005 5:26 am Post subject: post back value from smarty template |
|
|
Hi all,
just a quick question
if i want to return back a reserved variable with a value say name='postback'
*in thisTemplate.tpl*
{$smarty.server.post['postback'] = 'thisvalue'}
so that I can catch it in <?php
$postbackValue = $_pos['postback'];
?>
Thanks in advance |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Jun 27, 2005 2:13 pm Post subject: |
|
|
You create a form on a template:
Code: | <form action="{$SCRIPT_NAME}">
<input type="hidden" name="postback" value="thisvalue">
<input type="submit">
</form> |
When the form submits, the value is available in PHP: $_POST['postback']
Or, create a link in a template:
Code: | <a href="{$SCRIPT_NAME}?postback=thisvalue">click</a> |
Click the link and the value is available in PHP: $_GET['postback'] |
|
Back to top |
|
unidude Smarty n00b
Joined: 27 Jun 2005 Posts: 2
|
Posted: Mon Jun 27, 2005 11:34 pm Post subject: |
|
|
Thanks mohrt
I probablly didnt explain it better....sorry about that...
I have an IF statement in the template in which
{if condition true}
postback thisName = 'thisValue'
{else}
<select name='postback'>
<option value='value1'>value1</option>
<option value='value2'>value2</option>
...........................etc....
</select>
so what I am trying to achieve is when the condition is true it only displays a label field (not a text box , or a drop down list like if the condition is false) and I want to return that assigned value back to the php code from the template.
...later on I found what I did was to add the following code
<input type="hidden' name='postback' value='thisValue'>
it works fine.... |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Tue Jun 28, 2005 1:32 pm Post subject: |
|
|
Yep thats what I do, make it a hidden field. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|