Jump to content

Can't find search bar in product pages only on home page


Recommended Posts

Thank you for your suggestions. I played with the hooks but wasn't able to solve my initial problem.

It turns out it's a module called “savvy search autocomplete”. Anyhow, I can get it to show up on the homepage no problem but for some reason, It won't display in other pages. It has parts of it in the product pages, but it's missing the main input field ?!?!?!

Home page code: 

<form method="get" action="https://espacehabitationgbi.com/en/search" _lpchecked="1">
  <input type="hidden" name="controller" value="search"> 
  <input type="hidden" name="orderby" value="position"> 
  <input type="hidden" name="orderway" value="desc"> 
  <input type="text" class="ssa-search-query ssa-search-query-input form-control" name="search_query" value="" placeholder="Search">
  <button type="submit" name="ssa_submit" class="btn btn-default button-search ssa-button-search">
    <span class="material-icons search">Search</span>
  </button>
</form>

Other page code:

<form method="get" action="https://espacehabitationgbi.com/en/search"> 
  <input type="hidden" name="controller" value="search"> 
  <input type="hidden" name="orderby" value="position"> 
  <input type="hidden" name="orderway" value="desc">
</form>

 

I'm guessing there could have been some customization done, but I can't seem to figure out where to look first.

Link to comment
Share on other sites

Why do you have two different codes for displaying the form? Does the module have different hooks for each page? Try to copy code from the first form to the second form. It should resolve the problem

 

PS. Have you thought about improving the website's UX ;)

Link to comment
Share on other sites

3 minutes ago, Piotr3qx said:

Why do you have two different codes for displaying the form? Does the module have different hooks for each page? Try to copy code from the first form to the second form. It should resolve the problem

What I posted there is inspected code. So I'm not sure where it's coming from and where to copy to 🤷‍♂️.

 

I really thought this section was going to help me, but it has not.

135923166_ScreenShot2022-02-15at9_59_49AM.png.1f389828fe1bd804930e0b10fc5841e2.png

11 minutes ago, Piotr3qx said:

PS. Have you thought about improving the website's UX ;)

Of course, I just need to re-establish normal functionality of the backend, and I'm right on it!

Link to comment
Share on other sites

I looked in the .tpl file, and it's all there but it seems the problem lies else where. I turned on debugging and found this error:

Notice: Undefined index: id_lang in /home/rootgbiinter/public_html/cache/smarty/compile/8f/60/f6/8f60f620ee24b0220f23809bfb9af52c5af71a33.file.ac-input.tpl.php

and if I look in that smarty cache file you can clearly see this code: 

<?php if ($_smarty_tpl->tpl_vars['id_lang']->value == 1) { ?>
	<input type="text" class='ssa-search-query ssa-search-query-input form-control' name="search_query" value="<?php echo stripslashes(mb_convert_encoding(htmlspecialchars($_smarty_tpl->tpl_vars['ssa_search_query']->value, ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8')); ?>
" placeholder="<?php echo smartyTranslate(array('s' => 'Recherche', 'mod' => 'savvysearch'), $_smarty_tpl); ?>
" />
     <button type="submit" name="ssa_submit" class='btn btn-default button-search ssa-button-search'>
       <span class='material-icons search'>
         Rechercher
       </span>
	</button>
<?php } ?>
<?php if ($_smarty_tpl->tpl_vars['id_lang']->value == 2) { ?>
	<input type="text" class='ssa-search-query ssa-search-query-input form-control' name="search_query" value="<?php echo stripslashes(mb_convert_encoding(htmlspecialchars($_smarty_tpl->tpl_vars['ssa_search_query']->value, ENT_QUOTES, 'UTF-8', true), "HTML-ENTITIES", 'UTF-8')); ?>
" placeholder="<?php echo smartyTranslate(array('s' => 'Search', 'mod' => 'savvysearch'), $_smarty_tpl); ?>
" />

	<button type="submit" name="ssa_submit" class='btn btn-default button-search ssa-button-search'>
      <span class='material-icons search'>
        Search
      </span>
	</button>
<?php } ?>

So for some reason the id_lang is missing, and I don't know where it has gone. I checked the contents of $_smarty_tpl->tpl_vars, and it has just about everything except for the variables I'm looking for. I've placed a temporary workaround in the cached file, but would really like some help to find out why some of my data is gone. 

 

Thanks!

Link to comment
Share on other sites

No, it just looks like the full form with some class conditionals:


{strip}
{if !isset($ssa_typeblock) }
    {assign var="ssa_typeblock" value="custom" nocache}
{/if}

{assign var="ssa_add_class_container" value="" nocache}
{if $ssa_typeblock === 'top' || $ssa_typeblock === 'nav'}
    {assign var="ssa_add_class_container" value="col-sm-4" nocache}
{/if}

{if isset($ssa_mobilemode) && $ssa_mobilemode}
    {assign var="ssa_add_class_container" value="" nocache}
{/if}

{if $ssa_typeblock === 'column' }
    <div class='block'>
       <p class='title_block'>{l s='Search' mod='savvysearch'}</p>
{/if}
{/strip}
<div class='ssa-searchblock ssa-searchblock-{$ssa_typeblock|escape:'htmlall':'UTF-8'|stripslashes} {$ssa_add_class_container|escape:'htmlall':'UTF-8'|stripslashes} clearfix'>
    <form method="get" action="{$search_url|escape:'html':'UTF-8'|stripslashes}">
    <input type="hidden" name="controller" value="search" />
    <input type="hidden" name="orderby" value="position" />
    <input type="hidden" name="orderway" value="desc" />
    <input type="text" class='ssa-search-query ssa-search-query-input form-control'
           name="search_query"
           value="{$ssa_search_query|escape:'htmlall':'UTF-8'|stripslashes}"
           placeholder="{l s='Search' mod='savvysearch'}" />
    <button type="submit" name="ssa_submit" class='btn btn-default button-search ssa-button-search'><span class='material-icons search'>search</span></button>
    </form>
</div>
{strip}
{if $ssa_typeblock === 'column' }
    </div>
{/if}
{/strip}

 

Link to comment
Share on other sites

Nevermind, I found it. There was an override of the FrontController class that included this code :

<?php

class FrontController extends FrontControllerCore
{
   public function initHeader()
   {
      //create your variable
      self::$smarty->assign('id_lang', $this->context->language->id);
      self::$smarty->assign('id_shop', $this->context->shop->id);

      //call original method, to maintain default behaviour:
      return parent::initHeader();
   }
}

?>

 

Apparantly self::$smarty is deprecated and needs to be replaced with this:

<?php
class FrontController extends FrontControllerCore
{
   public function initHeader()
   {
      //create your variable
      $this->context->smarty->assign('id_lang', $this->context->language->id);
      $this->context->smarty->assign('id_shop', $this->context->shop->id);

      //call original method, to maintain default behaviour:
      return parent::initHeader();
   }
}
?>

 

Thanks for the help.

Link to comment
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...