Jump to content

compare.tpl also on search.tpl


Recommended Posts

To

Achieve compare Functionality on search.tpl

 

Replace following function in

searchController.php

 

public function displayContent()
{
	parent::displayContent();
             self::$smarty->assign('comparator_max_item', (int)(Configuration::get('PS_COMPARATOR_MAX_ITEM')));
            self::$smarty->display(_PS_THEME_DIR_.'search.tpl');
}

public function setMedia()
{
	parent::setMedia();

	if (!$this->instantSearch AND !$this->ajaxSearch)
		Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
               if (Configuration::get('PS_COMPARATOR_MAX_ITEM') > 0)
		Tools::addJS(_THEME_JS_DIR_.'products-comparison.js');
}

 

 

with the following function

 

public function displayContent()
{
	parent::displayContent();
               self::$smarty->display(_PS_THEME_DIR_.'search.tpl');
}

public function setMedia()
{
	parent::setMedia();

	if (!$this->instantSearch AND !$this->ajaxSearch)
		Tools::addCSS(_THEME_CSS_DIR_.'product_list.css');
       }

 

 

And Replace following line in search.tpl

Replace

 

{if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}
{include file="$tpl_dir./product-sort.tpl"}{/if}

 

 

With the

{if !isset($instantSearch) || (isset($instantSearch) && !$instantSearch)}
{include file="$tpl_dir./product-compare.tpl"}[attachment=41582:search-compare.txt]
{include file="$tpl_dir./product-sort.tpl"}{/if}

 

For the shake of Convenience I have attached a file having all Necessary code

search-compare.txt

Link to comment
Share on other sites

Hi Vivek,

 

I tried, but it does not work. Are you sure it works with 1.4.0.17 ? On the SearchController.php I have originally another code:

 

	public function displayContent()
{
	parent::displayContent();
	self::$smarty->display(_PS_THEME_DIR_.'search.tpl');
}

public function displayFooter()
{
	if (!$this->instantSearch AND !$this->ajaxSearch)
		parent::displayFooter();
}

 

By replacing the hack on both files, comparator does not appear and it duplicates my filterby search on the top of the page. Yes I also cleaned browser cache and smarty cache.

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...