Jump to content

custom search left column


Recommended Posts

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>
        <!-- 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">
        <!-- Button -->
        <div class="form-group">

          <div class="text-right">
            <button type="submit" id="pesquisarTinteirosBtn" name="pesquisarTinteirosBtn" class="btn btn-primary finalizarcompra">Pesquisar</button>
  {* search tinteiros end *}
  <div id="toControlSearchTinteiros" class="unvisible">{$path}</div>
        //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!");
        } else{
            //console.log("Value does not exists!");
        //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) !== '') {
                jQuery("li.nomargin > input").prop('disabled', true);
                jQuery("li.nomargin > input").prop('disabled', false);

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)
            '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'),

        $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 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?

Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More