Jump to content

Show Products On 404 / Pagenotfound


Recommended Posts

Hi,

I am new to prestashop and do not know which file to edit to include products on the 404 error page.

 

Can someone please post some instructions on where to edit which file?

 

I am using  1.6.1.3 Prestashop

 

I read this article 

 
thanks for any help  :)
 

 

 

Link to comment
Share on other sites

This is the content of 404.tpl

 

{*
* 2007-2015 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <[email protected]>
*  @copyright  2007-2015 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*}
<div class="pagenotfound">
	<h1>{l s='This page is not available'}</h1>

	<p>
		{l s='We\'re sorry, but the Web address you\'ve entered is no longer available.'}
	</p>

	<h3>{l s='To find a product, please type its name in the field below.'}</h3>
	<form action="{$link->getPageLink('search')|escape:'html':'UTF-8'}" method="post" class="std">
		<fieldset>
			<div>
				<label for="search_query">{l s='Search our product catalog:'}</label>
				<input id="search_query" name="search_query" type="text" class="form-control grey" />
                <button type="submit" name="Submit" value="OK" class="btn btn-default button button-small"><span>{l s='Ok'}</span></button>
			</div>
		</fieldset>
	</form>
	<div class="buttons"><a class="btn btn-default button button-medium" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl}{else}{$base_dir}{/if}" title="{l s='Home'}"><span><i class="icon-chevron-left left"></i>{l s='Home page'}</span></a></div>
</div>

I want to display the products on this pagenotfound 


how and where should this code be placed?

{hook::exec('displayHomeTabContent')} 

Edited by othreed (see edit history)
Link to comment
Share on other sites

Try to paste it at the end, you will also need to modify the homefeatured.php module:

public function hookHeader($params)
	{
		if (isset($this->context->controller->php_self) && ($this->context->controller->php_self == 'index')
            || ($this->context->controller->php_self == 'pagenotfound'))
			$this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
		$this->context->controller->addCSS(($this->_path).'css/homefeatured.css', 'all');
	}
Link to comment
Share on other sites

thank you for your kind help

I added the following code to file:
modules/homefeatured/homefeatured.php

public function hookHeader($params)
    {
        if ((isset($this->context->controller->php_self) && ($this->context->controller->php_self == 'index')
|| ($this->context->controller->php_self == 'pagenotfound'))
            $this->context->controller->addCSS(_THEME_CSS_DIR_.'product_list.css');
        $this->context->controller->addCSS(($this->_path).'css/homefeatured.css', 'all');
    }

but the products are not displayed...

any suggestions?

Link to comment
Share on other sites

thank you very much for the help  &  sorry for the misunderstanding 

 

After disabling cache it worked :)

 

 

 I modified the hookHeader function accordingly by adding the code

|| ($this->context->controller->php_self == 'pagenotfound'))

 

at line 117

 

and also added the {hook::exec('displayHomeTabContent')}

 

to the end of 404.tpl.

 

 

now all products which have the category "home" checked are displayed ..

 

Also there are two blue banners with text:
1.there are no new products.

2. there are no Discount products

 

now I will try to figure out why it displays thouse banners...

 

Screen_Shot_2015_12_24_at_14_51_23.png

Edited by othreed (see edit history)
Link to comment
Share on other sites

Those banners are displayed because it replicates the tabs behavior from the homepage. And there you have tabs with new, featured and discount products.

 

So it also appears here. I tried to turn it by setting exceptions but it didn't work. But you can hide them with css rules:

 

Try adding this to your global.css:

#pagenotfound #blocknewproducts,
#pagenotfound #blockbestsellers,
#pagenotfound #blockspecials {
   display: none;
}
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...