Forums / Setup & design / How to customise error messages ?

How to customise error messages ?

Author Message

Xavier Dutoit

Tuesday 29 March 2005 12:01:13 am

Hi,

I'm trying to display a different message when the user tries to access a restricted area and when he tries to put a product in the basket.

The page involved in both case is the templates/errors/kernel/1.tpl (I've copied it into my custom design folder).

However, none of the variables I could think of (the usual suspects: module_result, view_parameters, uri_string, requested_uri_string) are set and designkeys only contains the section id.

How do I know that I'm in /shop/basked or in /private_area ?
On the log: I've got this message

"Warning: Insufficient permissions  	Mar 29 2005 09:52:33

Function required:
 Module : shop
 Function : buy
 ClassID : 
 MainNodeID : 
Policies that didn't match:

I want to be able to know on 1.tpl if I'm on the shop module or content one for instance, so I can customise the error message (the default one isn't the most selling one for a shop ;)

Any idea ?

X+

 

http://www.sydesy.com

Łukasz Serwatka

Tuesday 29 March 2005 3:16:38 am

Hi Xavier,

You can use sections and information stored in $parameters.

{section loop=$parameters.AccessList.FunctionRequired}
    {$item}
{/section}

For example if you want to show some information for Anonymous user who want access folder with node id 97

{section show=eq( $parameters.AccessList.FunctionRequired.MainNodeID, 97 )}
    Show something or include some tpl
{/section}

For shop

{section show=eq( $parameters.AccessList.FunctionRequired.Module, 'shop' )}
    Show something or include some tpl
{/section}

I hope it will help.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Xavier Dutoit

Tuesday 29 March 2005 9:31:25 am

Hi,

thanks for your answer, I wasn't aware of the parameters variable. What is it ? Is that going to be covered in the doc ?

I don't quite really get why you haven't reused the same variables than the usual "module_result, view_parameters, uri_string, requested_uri_string" instead, but variable proliferation in ez is another topic altogether ;)

For the record, I found antother less elegant way:

{section show=eq($redirect_uri,"/shop/basket")}

Because I forgot to subscribe to this thread to get emails when someone post ;(

http://www.sydesy.com

Łukasz Serwatka

Wednesday 30 March 2005 5:41:17 am

New documentation is a part of 3.6 cycle and will contains lots of new content/material.

$parameters variable stores extra informaion about:
- function
- module
- polices

{$parameters|attribute}

Alternative, you can use string functions and fetch info about node (if exists).

{let uri_data=$redirect_uri|explode( '/' )
     node_data=fetch( content, node, hash( node_id, $uri_data[4] ) )}
	{$node_data.name}
{/let}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Nathan Kelly

Friday 04 November 2005 7:43:00 pm

Hi, is there any way to override error messages, I don't want to change core files even if its only cosmetic text changes, so if there is a way to override them.

The message in question is kernel(20) among others, the reason is that if a user is presented with a statement like "This site uses siteaccess matching in the URL and you didn't supply one, try inserting a siteaccess name before the module in the URL ." how on earth will they know what "siteaccess" means?

What i'd like to do is replace this statement with a message such as "try searching the site" and place a search form on the "module not found" page, I think this would be more user friendly.

Is there any way this could be done?

Cheers!

Pardon me while I burst into flames...