Forums / Developer / Removing custom module index page ?

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

eZ debug

Timing: Jan 18 2025 15:14:08
Script start
Timing: Jan 18 2025 15:14:08
Module start 'content'
Timing: Jan 18 2025 15:14:08
Module end 'content'
Timing: Jan 18 2025 15:14:08
Script end

Main resources:

Total runtime0.2027 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.7344180.8281
Module start 'content' 0.00690.0055 768.562598.0078
Module end 'content' 0.01240.1902 866.5703526.7969
Script end 0.2026  1,393.3672 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00422.0692200.0002
Check MTime0.00221.0727200.0001
Mysql Total
Database connection0.00070.353310.0007
Mysqli_queries0.157177.51221410.0011
Looping result0.00150.73061390.0000
Template Total0.189793.610.1897
Template load0.00120.588210.0012
Template processing0.188593.015610.1885
Override
Cache load0.00090.463910.0009
Sytem overhead
Fetch class attribute can translate value0.00070.329210.0007
XML
Image XML parsing0.00030.162310.0003
General
dbfile0.00200.9941200.0001
String conversion0.00000.015830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/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