Jump to content

pass smarty template variable to php code?


Recommended Posts

Hi,

I am just a newbie in prestashop. Currently I am doing a module. In that module I have a form in smarty in left column.

The form is like this

<div id="search-block-wrap">
  <table id="search">
    <tr>
      <td width="200" valign="top">
        <input type="text" name="search" />
      </td>
      <td>
        <input id="search-here" type="submit" value="search" name="search" />
      </td>
    </tr>
  </table>
</div>

so when someone will give one product name in the search box and will click on search it will display the product details.

Here my doubt is how can I pass the entered values in form which is in smarty to the php code? How to do this?
 

Link to comment
Share on other sites

 

if you've got there form with submit button, you can handle POST variables in your hook. for example

if (Tools::isSubmit('somefield')){
do_something();
}

But how can I pass all the varaibles from smarty? As my form is now in smarty template?

You have told to use

if (Tools::isSubmit('somefield')){
do_something();
}

but as I know that can be used in module's php file inside getContent() function. But in smarty how can I do this?

Link to comment
Share on other sites

i don't understand your expectactions.

 

you've got form in left column of your website

if there is sumit button, you can handle these fields 

 

<input name="myfield" />

<input name="example" />

 

in your module php core with something like i suggested above. in this case, code  looks like:

if (Tools::isSubmit('myfield')){
do_something();
}

in smarty you can't use PHP code. (in prestashop 1.5.x)

Link to comment
Share on other sites

×
×
  • Create New...