Premizlaus Posted February 26, 2018 Share Posted February 26, 2018 (edited) Hello !!! How to get variable from input dynamically in smarty. THX Edited February 27, 2018 by Premizlaus (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted February 27, 2018 Share Posted February 27, 2018 Step 1: get the posted value: $myvar = Tools::getValue('myfield') step 2: assign it to Smarty $this->context->smarty->assign('smartvar', $myvar); Link to comment Share on other sites More sharing options...
Premizlaus Posted February 27, 2018 Author Share Posted February 27, 2018 (edited) ok i have now in php public static function PriceFilter() { $cena1 = $_POST['price1']; $cena2 = $_POST['price2']; return '2-strona-glowna?q=Cena-zł-'.$cena1.'-'.$cena2.''; } tpl <form action="{WszystkieProduktyControllerCore::PriceFilter()}" id="layered_form" method="post"> <div class="filtr-od"> od <input name="price1" value="50" class="inputek layered_price_range layered_input_range_min layered_input_range form-control grey" id="layered_price_range_min" type="text"></input> <span class="layered_price_range_unit"> zł </span> </div> <div class="strzalka-filtr-cena"></div> <div class="filtr-do"> do <input name="price2" value="200" class="inputek layered_price_range layered_input_range_max layered_input_range form-control grey" id="layered_price_range_max" type="text"></input> <span class="layered_price_range_unit"> zł </span> </div> <span class="layered_price_format" style="display:none;"> 2 </span> </div> <div class="szukajka"> <input class="btn btn-primary fa fa-filter" type="submit" value="Filtruj"/> </div> </form> but action from form not working at firs time. This is code for filter price. Edited February 27, 2018 by Premizlaus (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted February 27, 2018 Share Posted February 27, 2018 I don't get your point. You didn't use the code I showed. Link to comment Share on other sites More sharing options...
Premizlaus Posted February 27, 2018 Author Share Posted February 27, 2018 Your code is to be in init function controller yes? I can not find controller for layout-left-column.tpl. Can I add a second one? Sorry im new in presta Link to comment Share on other sites More sharing options...
Premizlaus Posted February 27, 2018 Author Share Posted February 27, 2018 (edited) the same as with my code the first time the post does not catch up to action Edited February 27, 2018 by Premizlaus (see edit history) Link to comment Share on other sites More sharing options...
musicmaster Posted February 27, 2018 Share Posted February 27, 2018 (edited) 1 hour ago, Premizlaus said: Your code is to be in init function controller yes? I can not find controller for layout-left-column.tpl. Can I add a second one? There is no code for the left column. The left column is populated by modules. You should check the module code and templates. 8 minutes ago, Premizlaus said: blank page if i use $myvar = Tools::getValue('myfield') anywhere in php Just check the code and you will find probably hundreds of " Tools::getValue()" in Prestashop's PHP. If it doesn't work for you to copy such a line you are doing something wrong. But of course it might be that in your Prestashop version it works slightly different. You didn't mention your PS version. Edited February 27, 2018 by musicmaster (see edit history) Link to comment Share on other sites More sharing options...
Premizlaus Posted February 27, 2018 Author Share Posted February 27, 2018 prestashop 1.7 Link to comment Share on other sites More sharing options...
Premizlaus Posted February 27, 2018 Author Share Posted February 27, 2018 Maybe there is another solution to make it work. Link to comment Share on other sites More sharing options...
musicmaster Posted February 28, 2018 Share Posted February 28, 2018 Sure, you can think up your own code. You can also look how it is done by Prestashop in the files in /controllers/front Link to comment Share on other sites More sharing options...
Premizlaus Posted February 28, 2018 Author Share Posted February 28, 2018 I used javascript for this though I did not want to Link to comment Share on other sites More sharing options...
musicmaster Posted February 28, 2018 Share Posted February 28, 2018 ok Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now