Jump to content

how to create custom 404?


Recommended Posts

But you can modify 404.tpl page to show your CMS content... you don't have to create separate pages etc.

thanks. But I would need to create a CMS page called 404 which I configure to my needs, right? Can you give me a hint what to change in the 404.tpl to redirect to the CMS page then? Thanks
Link to comment
Share on other sites

You can redirect customers with this simple script:

 

<script language=”JavaScript”>
self.location=”PAGE_URL_HERE”;
</script>

 

you have to put this code into the 404.tpl file. I'm looking for some other method in prestashop classes, maybe i will find it

 

but i suppose that this isn't what you exactly expect

  • Thanks 1
Link to comment
Share on other sites

You can redirect customers with this simple script:

 

<script language=”JavaScript”>
self.location=”PAGE_URL_HERE”;
</script>

great. Thanks a lot. So I delete all major content in the 404.tpl and just copy that code above?

 

And no I do not need any classes fix. Too complicated for me ;-)

 

you have to put this code into the 404.tpl file. I'm looking for some other method in prestashop classes, maybe i will find it

 

but i suppose that this isn't what you exactly expect

Link to comment
Share on other sites

hello

 

i checked prestashop 1.4.8.2 files and it works exactly the same as it works in 1.5.x

 

404.php

require_once(dirname(__FILE__).'/config/config.inc.php');
ControllerFactory::getController('PageNotFoundController')->run();

 

 

PageNotFoundController:

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

 

sot as you can see, this is 404.tpl located in your theme directory...

  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...
  • 4 years later...
On 8/5/2013 at 5:21 PM, vekia said:

But you can modify 404.tpl page to show your CMS content... you don't have to create separate pages etc.

Hi Vekia,

the post is very old, I know, and I'm using PS 1.7.3,  but how can I modify 404.tpl page to show CMS content?!

TY very much!!!

Link to comment
Share on other sites

  • 1 year later...
On 3/19/2018 at 7:01 PM, Luca said:

Hi Vekia,

the post is very old, I know, and I'm using PS 1.7.3,  but how can I modify 404.tpl page to show CMS content?!

TY very much!!!

My answer is quite old too but i needed it in an 1.7.5 shop

https://www.majory-cubizolles.fr/blog/inserer-une-page-cms-sur-une-page-produit-astuce-prestashop/
https://stackoverflow.com/questions/16449583/show-a-smarty-variable-with-html-content/33900878

Call your content in the tpl file templates/errors/not-found.tpl :

{* 16 is the CMS Page used to store the message *}
{assign var=cms_content value=CMS::getCMSContent(16)}
{if $cms_content.content}
	<div class="contentCms">
	{$cms_content.content nofilter}
	</div>
{else}
	{* default message *}
	<h4>{l s='Sorry for the inconvenience.' d='Shop.Theme.Global'}</h4>
	<p>{l s='Search again what you are looking for' d='Shop.Theme.Global'}</p>
{/if}

 

 

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