21282 Posts in 5730 Topics by 2601 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 118 Views |
-
url_handlers in 3.0

22 January 2013 at 12:53am
Hi.
I've been googling this for the last half an hour, and no success.
I cannot find any good tutorial about url_handlers.
What I need to make working is:1. I have a MyPage class and an instance with a following URLSegment: 'http://mydomain.com/mypage'
2. Now I need to support ANY action in this page class: 'http://mydomain.com/mypage/lorem' should open 'http://mydomain.com/mypage' with Action param: 'lorem'.I declared this in MyPage_Controller:
public static $url_handlers = array(
'' => 'index',
'$Action' => 'index',
);public function index() {
print_r($this->getRequest()->params());
return array();
}but calling http://mydomain.com/mypage/lorem gives me the following error:
[Warning] substr() expects parameter 1 to be string, array given
GET /mypage/lorem
Line 79 in /var/www/vhosts/pitax.internetex.pl/htdocs/framework/control/ContentNegotiator.phpHowever it prints the params correctly:
Array ( [URLSegment] => mypage [Action] => lorem [ID] => [OtherID] => [Controller] => ModelAsController )
so that 'lorem' is considered as an Action.anyone know what's wrong here?
-
Re: url_handlers in 3.0

22 January 2013 at 1:04am Last edited: 22 January 2013 1:04am
and the stack trace:
Trace
substr(Array,0,5)
ContentNegotiator.php:79
ContentNegotiator::enabled_for(SS_HTTPResponse)
ContentNegotiator.php:83
ContentNegotiator::process(SS_HTTPResponse)
Controller.php:174
Controller->handleRequest(SS_HTTPRequest,DataModel)
ContentController.php:197
ContentController->handleRequest(SS_HTTPRequest,DataModel)
ModelAsController.php:68
ModelAsController->handleRequest(SS_HTTPRequest,DataModel)
Director.php:307
Director::handleRequest(SS_HTTPRequest,Session,DataModel)
Director.php:119
Director::direct(/mypage/lorem,DataModel)
main.php:126 -
Re: url_handlers in 3.0

24 January 2013 at 5:42am
what is the purpose of "return array()" in the index function? Removing that fixes the error for me.
| 118 Views | ||
|
Page:
1
|
Go to Top |


