Damien POBEL wrote: > Hello, > > I'm writing a simple application using ez components (from SVN), I use > ezcUrl and I have a problem with it. > > My application uses three types of URL : > http://domain.com/index.php > http://domain.com/index.php/group/id > http://domain.com/index.php/group/(page)/p > > So I wrote this code to recognize which page is called : > > <?php > require_once 'ezc.php'; // autoloads > > $urlCfg = new ezcUrlConfiguration(); > $urlCfg->basedir = '/'; > $urlCfg->script = 'index.php'; > $urlCfg->unorderedDelimiters = array( '(', ')' ); > $urlCfg->addUnorderedParameter( 'page', > ezcUrlConfiguration::SINGLE_ARGUMENT ); > $urlCfg->addOrderedParameter( 'group' ); > $urlCfg->addOrderedParameter( 'id' ); > $url = new ezcUrl( $my_url, $urlCfg ); > > header('Content-Type: text/plain'); > $group = $url->getParam( 'group' ); > $id = $url->getParam( 'id' ); > $page = $url->getParam( 'page' ); > > var_dump($group); > var_dump($id); > var_dump($page); > ?> > > I made some test with this code on > http://archives-newsgroups.pwet.fr/test_url.php. > > With http://domain.com/index.php/group/(page)/p in $my_url, I expected > $id to be null et $page to be equal to 'p' because it's an unordered > parameter, but $id is equal to '(page)'. is it normal ?
Hi Damien, Yes the behaviour you see is actually normal. In the case of 'http://domain.com/index.php/group/(page)/p', the configuration that you use expects an 'id' to be after 'group', and '(page)' is the next element after 'group', so it is assigned to the 'id' parameter (there is no way of knowing that the id is missing and an unordered parameter begins, because even ordered parameters can have delimiters). To be able to use multiple types of URLs, you can take a look at the tutorial_cfg_change.php (in the Url/docs/tutorial folder, or in the online documentation [1]) which shows how to use multiple URL configurations. Hope this helps. Let me know if you encounter problems. Cheers, Alex. [1] http://ez.no/doc/components/view/trunk/(file)/introduction_Url.html#changing-a-url-configuration-dynamically -- Alexandru Stanoi eZ Components System Developer eZ Systems | http://ez.no -- Components mailing list [email protected] http://lists.ez.no/mailman/listinfo/components
