Modules not getting called with params from pretty URL

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
MLdB
New Member
New Member
Posts: 6
Joined: Fri Feb 10, 2012 5:41 pm

Modules not getting called with params from pretty URL

Post by MLdB »

I previously posted this problem under Modules. I now realise the problem is with (my installation of) CMSMS.

I have a simple question, at least to someone familiar with the source code of CMSMS:

from index.php, the function get_pageid_or_alias_from_url() is called (lib/page.functions.php)

Here the global variable $_REQUEST is populated with parameters from the (pretty) URL if a route can be matched.

I assumed that when the module that registered the route is subsequently called from within the template, the variable $params it receives, contains the relevant key => value pairs taken from $_REQUEST.

But it doesn't.

Adding the code below to action.default.php of the module (in this case Gallery)

Code: Select all

print_r($params);
print_r($_REQUEST);
returns:

Code: Select all

Array ( [module] => Gallery [action] => default )
Array ( [page] => Gallery/'folder'/'returnid'/ [cntnt01dir] => 'folder' [cntnt01returnid] => 'returnid' [cntnt01action] => default [cntnt01module] => Gallery [mact] => Gallery,cntnt01,default,0 )
(Some key => value pairs are excluded and 'folder' and 'returnid' are placeholders for the actual values, naturally)

So, although $_REQUEST contains the correct parameters dir and returnid, $params does not.

The Gallery module (by Jos) does check for $params['dir'] at several places in its action.default.php, never for $_REQUEST['cntnt01dir'].

Does anyone have previous experience with params from pretty URLs being extracted correctly by get_pageid...() but not being passed to the module?

It would be a great help if someone could just point to where (which CMSMS source file (and function)) the key => value pairs from $_REQUEST are copied to $params available to the module.
MLdB
New Member
New Member
Posts: 6
Joined: Fri Feb 10, 2012 5:41 pm

Re: Modules not getting called with params from pretty URL

Post by MLdB »

I still really need some help on this one. So please, anyone who can clarify this, reply.

There is a function in lib/page.functions.php named get_pageid_or_alias_from_url(). The block comment above it reads:

Code: Select all

/* A function tat, given the current request information will return
 * a pageid or an alias that should be used for the display
 * This method also handles matching routes and specifying which module
 * should be called with what parameters
 */
The function goes to great lengths to gather all parameters from the 'pretty' URL, merging those with the default values specified by the module's registerRoute call and collecting them as key => value pairs in a local array $matches. But $matches is never returned or made available outside the function as far as I can see.

I can't be the only one finding this a bit odd...

Please any info on where the pretty URL really IS chopped into parameters and passed to a variable that can be read by the module (i.e. $params)
Post Reply

Return to “CMSMS Core”