Removing custom module index page ?

Author Message

H-Works Agency

Wednesday 15 July 2009 1:33:08 am

Say you make a custom module named "custom" with starting page "index.php" and with params "contentNodeID"

In module.php you would have :

$ViewList['index'] = array( 'script' => 'index.php',
'params' => array( 'contentNodeID' ));

In this case the page url would be : "domaine/custom/index/39483"

Then i want to remove "index" from the url like this :

$ViewList[''] = array( 'script' => 'index.php',
'params' => array( 'contentNodeID' ));

In this case the page url should be : "domaine/custom/39483"

The problem is that due to the contentNodeID param this syntax causes an error.

In fact it works if you just hit : "domaine/custom/" but not with the param.

Is there something i am missing to have this syntax working with module params ?

I hope my description is clear enough. Cheers. M

EZP is Great

André R.

Wednesday 15 July 2009 2:33:35 am

I'm amazed that $ViewList[''] is valid php, but anyway, doesn't seemd to work. If the module only have one view, then you should look into using the singel function support.

HowTo: Avoid defining $ViewList, and just define the singel function in $Module['function'] like:

$Module = array( 'name' => 'Custom',
                 'variable_params' => true,
                 'function' => array( 'script' => 'index.php',
                                             'params' => array( 'contentNodeID' ) )
);

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

H-Works Agency

Wednesday 15 July 2009 2:50:34 am

This technique allow to make compact module adresses by removing the second element in module's view uri.

But my exemple is not only for a "one view module" but to define a module "index" page...after $ViewList[''] you can add $ViewList['myview'].

The second benefit of defining this "empty" view is that people playing with their browser address won't arrive on a "undefined view" error when removing module's view name from the address.

I wasn't aware of your technique, i am gonna try it right away.

Thanx

EZP is Great

Bartek Modzelewski

Wednesday 15 July 2009 3:08:03 am

Hi Martin,

have you tried to use URL Translator in admin interface, and setup the following rule:

New URL alias: custom
Destination: custom/index
and remeber to uncheck "Alias should redirect to its destination".

I use it in my custom module, in fact without any params, but i think it should work also with params. Maybe just you will have to use different alias name than your module... (not sure about it)

Baobaz
http://www.baobaz.com

H-Works Agency

Wednesday 15 July 2009 3:21:20 am

I tried andre's way and its perfect for what i need...the only problem is that you can't add new module views to the module after that.

I thought about using url_translation module, i am gonna test it to see if it works with wildcards.

Thanx

EZP is Great

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 30 2025 21:41:58
Script start
Timing: Jan 30 2025 21:41:58
Module start 'layout'
Timing: Jan 30 2025 21:41:58
Module start 'content'
Timing: Jan 30 2025 21:42:00
Module end 'content'
Timing: Jan 30 2025 21:42:00
Script end

Main resources:

Total runtime1.2056 sec
Peak memory usage8,192.0000 KB
Database Queries65

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 588.1406151.2109
Module start 'layout' 0.00590.0041 739.3516220.7031
Module start 'content' 0.01001.1948 960.05474,511.5313
Module end 'content' 1.20470.0008 5,471.585915.8438
Script end 1.2056  5,487.4297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3233160.0002
Check MTime0.00130.1117160.0001
Mysql Total
Database connection0.00090.077310.0009
Mysqli_queries1.104091.5709650.0170
Looping result0.00070.0563630.0000
Template Total1.146695.120.5733
Template load0.00230.189920.0011
Template processing1.144394.913920.5721
Template load and register function0.00100.086710.0010
states
state_id_array0.00250.206210.0025
state_identifier_array0.00250.203520.0012
Override
Cache load0.00200.1670390.0001
Sytem overhead
Fetch class attribute can translate value0.00190.157030.0006
Fetch class attribute name0.00240.200270.0003
XML
Image XML parsing0.00120.099230.0004
class_abstraction
Instantiating content class attribute0.00000.001890.0000
General
dbfile0.00220.1790240.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs