ruisonika Posted December 30, 2020 Share Posted December 30, 2020 Hello guys Does anybody knows how to do this: I wanna create a special search form in left column with a select and a input to perform and show the result in center column. My real problem is how to perform submit query and the result show in center column. I've made all hardcoded because i don't know how to make a module on it's own (my bad). So this is my header.tpl with all the features that i wanna control client-side. {if isset($left_column_size) && !empty($left_column_size)} <div id="left_column" class="sidebar column col-xs-12 col-sm-12 col-md-{$left_column_size|intval} col-lg-{$left_column_size|intval} offcanvas-sidebar"> {* search tinteiros start *} <div id="pesquisaTinteiros" class="row box" style="display:none;"> <div class="col-xs-12"> <form class=""> <!-- Form Name --> <p class="page-subheading">Pesquise o seu consumível</p> <!-- Select Basic --> <div class="form-group"> <div class=""> <select id="isthereanyvalue" name="isthereanyvalue" required class="form-control"> <option value="">Marca do Equipamento</option> {foreach from=$equipamentos key=k item=equipamento} <option value="{$equipamento.m_equipa}" style="text-transform:uppercase;">{$equipamento.m_equipa}</option> {/foreach} </select> </div> </div> <!-- Text input--> <div class="form-group"> <div class=""> <input id="textinput" name="textinput" type="text" required placeholder="Modelo do equipamento" class="form-control input-md"> </div> </div> <!-- Button --> <div class="form-group"> <div class="text-right"> <button type="submit" id="pesquisarTinteirosBtn" name="pesquisarTinteirosBtn" class="btn btn-primary finalizarcompra">Pesquisar</button> </div> </div> </form> </div> </div> {* search tinteiros end *} {$HOOK_LEFT_COLUMN} <div id="toControlSearchTinteiros" class="unvisible">{$path}</div> </div> {/if} <script> {literal} //if the main category is tinteiros e toners var x = {/literal}'{$path}'{literal}; // Check if a value exists in breadcrumb array if(x.indexOf("Tinteiros e Toners") !== -1){ //console.log("Value exists!"); document.getElementById("pesquisaTinteiros").classList.remove("unvisible"); } else{ //console.log("Value does not exists!"); document.getElementById("pesquisaTinteiros").classList.add("unvisible"); } //if there is an option selected in select removes disabled from search (submit button) and disable input checkboxes in filters $('#isthereanyvalue').on('change', function () { $('#pesquisarTinteirosBtn').prop('disabled', !$(this).val()); if ((this.value) !== '') { $('#pesquisarTinteirosBtn').css('opacity','1'); $('#layered_block_left').css('opacity','.3'); jQuery("li.nomargin > input").prop('disabled', true); $('.layered_price').css('display','none'); }else{ $('#pesquisarTinteirosBtn').css('opacity','.3'); $('#layered_block_left').css('opacity','1'); jQuery("li.nomargin > input").prop('disabled', false); $('.layered_price').css('display','block'); } }).trigger('change'); {/literal} </script> In FrontController.php i've added the following code to populate options on select public function initHeader() { /** @see P3P Policies (http://www.w3.org/TR/2002/REC-P3P-20020416/#compact_policies) */ header('P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"'); header('Powered-By: PrestaShop'); // Hooks are voluntary out the initialize array (need those variables already assigned) $this->context->smarty->assign(array( 'time' => time(), 'img_update_time' => Configuration::get('PS_IMG_UPDATE_TIME'), 'static_token' => Tools::getToken(false), 'token' => Tools::getToken(), 'priceDisplayPrecision' => _PS_PRICE_DISPLAY_PRECISION_, 'content_only' => (int)Tools::getValue('content_only'), )); $this->context->smarty->assign($this->initLogoAndFavicon()); $rows = Db::getInstance()->executeS(' SELECT id_product FROM `'._DB_PREFIX_.'cart_product` WHERE `id_cart` = '.(int)$this->context->cookie->id_cart); // or distinct products //$rows = Db::getInstance()->executeS(' // SELECT DISTINCT id_product // FROM `'._DB_PREFIX_.'cart_product` // WHERE `id_cart` = '.(int)$this->context->cookie->id_cart); $rows = ($rows) ? $rows : array(); $this->context->smarty->assign('cart_rows',count($rows)); ////////////this is to populate options on select//////////// $sql = Db::getInstance()->executeS(" SELECT DISTINCT m_equipa FROM ps_product WHERE m_equipa != 'NULL' "); $rows2 = ($sql) ? : array(); $this->context->smarty->assign('equipamentos', $rows2); ////////////////////////////////////////////////////////// } Can someone help me to finalize this? Show the result of the products performed by query of form submit in center column? 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