Re: [SMARTY] How to pass parameters in the registered function

From: Date: Tue, 18 Feb 2003 11:21:44 +0000
Subject: Re: [SMARTY] How to pass parameters in the registered function
References: 1 2  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7818@lists.php.net to get a copy of this message
On Tue, Feb 18, 2003 at 04:06:11PM +0500, Semenov Dmitry wrote: > Hello I have the following function > > function search_form($search_field_array, $script_name) > { > ?> > <form name="search_form" method="post" > action="<?=$script_name?>" style="display:inline;"> > <? > la la la la la > and foreach actions with thr $search_field_array > } > > In my smarty I did the follwing > $smarty->register_function("search_form", "search_form"); > > My template contain the next smarty tag > {search_form} > > And here is the problem > After the tempate was parsed I see the following html code inside it > > <form name="search_form" method="post" action="Object" > style="display:inline;" > > How can I set the parameters for my function? > I do not like to see "Object" as my action, I want to see test.php for > example there. your php-function has to be declared in a special way, if it is a smarty-function function search_form($params, &$smarty) { ... } see: http://smarty.php.net/manual/en/plugins.functions.php if you call it then: {search_form fields=$array script_name="test.php"} you can acces $params['script_name'] and $params['fields'][...] if $array was an array that was assigned to the template. the second paramter $smarty points to the $smarty-object that was called with ->display (or ->fetch) to display the template that contained your {search_form ...} HTH messju > Help me please. > > Best wishes, > Dmitry.

« previous php.smarty.general (#7818) next »