This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Removing custom module index page ?

Removing custom module index page ?

Removing custom module index page ?

Wednesday 15 July 2009 10:33:08 am - 4 replies

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

Wednesday 15 July 2009 11: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' ) )

Modified on Wednesday 15 July 2009 11:34:08 am by André R

Wednesday 15 July 2009 11: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.


Wednesday 15 July 2009 12:08:03 pm

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)

Modified on Wednesday 15 July 2009 12:08:55 pm by Bartek Modzelewski

Wednesday 15 July 2009 12:21:20 pm

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.



You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from