Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-22-2008, 01:58 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default Why Route doesn't work?

Hi,

Why this regex route doesn't match the module?
$router->addRoute(
'regex1',
new Zend_Controller_Router_Route_Regex(
'tcontrol/(.+/)*',
array(
'module'=>'mod',
'controller' => 'control',
'action' => 'index'
),
array(
1 => 'action'
)
)
);
With url : http://www.example.com/tcontrol/cale.../p3/tyu/p4/hjk
array(7) {
["controller"]=>
string(7) "tcontrol"
["action"]=>
string(10) "calendar"
["p1"]=>
string(2) "jh"
["p2"]=>
string(3) "ert"
["p3"]=>
string(3) "tyu"
["p4"]=>
string(3) "hjk"
["module"]=>
string(7) "default"
}

Thks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-22-2008, 05:20 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default

I'd tried:

$router->addRoute(
'regex1',
new Zend_Controller_Router_Route_Regex(
'tcontrol/(.+?)/*',
array(
'module'=>'mod',
'controller' => 'tcontrol',
'action' => 'index'
),
array(
1 => 'action'
)
)
);
Na url :
http://www.example.com/tcontrol/cale.../p3/tyu/p4/hjk
array(3) {
["action"]=>
string(37) "calendario/p1/jh/p2/ert/p3/tyu/p4/hjk"

["module"]=>
string(3) "mod"
["controller"]=>
string(7) "control"
}

What's wrong?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-24-2008, 04:27 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

When you're module name isn't default, your url should be prefixed with it. If you do that, and have a proper dir layout, you won't need to add a route like that. Just path to it with:

example.com/mod/tcontrol/calendario/p1/jh/p2/ert/p3/tyu/p4/hjk

The rest of the URL can just be picked out with getParams()
__________________
- xentek
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-24-2008, 04:30 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default

But I need an url without a module and with a module.

And now?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-24-2008, 04:31 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

You always have a module. The default module is 'default'.
__________________
- xentek
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-24-2008, 04:33 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default

I know. But why the route doesn't work?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-24-2008, 04:37 PM
xentek's Avatar
Senior Member
 
Join Date: Feb 2008
Posts: 112
Default

Well, from what I can tell in your example code above - you are trying to force a 'default' module URL to fit to a 'mod' module URL. If that's not what you are trying to do, then please repost your code in a readable format.

Try surrounding them in php bbcodes so that it help format it for you.
__________________
- xentek
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-24-2008, 04:44 PM
Junior Member
 
Join Date: Mar 2008
Posts: 5
Default

PHP Code:
$router->addRoute(
'regex1',
new 
Zend_Controller_Router_Route_Regex(
'tcontrol/(.+?)/*',
array(
'module'=>'mod',
'controller' => 'tcontrol',
'action' => 'index'
),
array(
=> 'action'
)
)
); 
Na url :
http://www.example.com/tcontrol/cale.../p3/tyu/p4/hjk
PHP Code:
array(3) {
[
"action"]=>
string(37"calendario/p1/jh/p2/ert/p3/tyu/p4/hjk"
["module"]=>
string(3"mod"
["controller"]=>
string(7"control"

All the params goes with the action.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-25-2008, 10:58 PM
Junior Member
 
Join Date: Mar 2008
Posts: 8
Default

Hi,

Can I ask you why don't use Zend_Controller_Router_Route ??

Code:
$router->addRoute('route1',new Zend_Controller_Router_Route(
'tcontrol/:param1/*',
array(
'module'=>'mod',
'controller' => 'tcontrol',
'action' => 'index',
'param1' => 'action'
)));
I don't know about regex, but (.+?) excludes '/'? At doc (Zend Framework: Documentation) they use /* for parameters, after define module, controller and action (I don't know if this is important)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 08:45 PM.