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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 06:23:29
Script start
Timing: Jan 19 2025 06:23:29
Module start 'layout'
Timing: Jan 19 2025 06:23:29
Module start 'content'
Timing: Jan 19 2025 06:23:29
Module end 'content'
Timing: Jan 19 2025 06:23:29
Script end

Main resources:

Total runtime0.0142 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 589.1563152.6250
Module start 'layout' 0.00520.0027 741.781339.4609
Module start 'content' 0.00790.0043 781.242297.4609
Module end 'content' 0.01220.0020 878.703138.3047
Script end 0.0142  917.0078 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002416.7917140.0002
Check MTime0.00107.1696140.0001
Mysql Total
Database connection0.00096.321910.0009
Mysqli_queries0.002316.432530.0008
Looping result0.00000.083910.0000
Template Total0.001711.810.0017
Template load0.00096.279910.0009
Template processing0.00085.455710.0008
Override
Cache load0.00064.534110.0006
General
dbfile0.00021.542780.0000
String conversion0.00000.057140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs