开发者

Put multiple segments of URL in 1 variable with Zend

For a new application I'd like to work with the URI to determine what content should be loaded. Nothing special so far ... But how can I let the slug have slash(es) in it and make sure Zend Framework sees them as 1 variable? ZF splits the requested URL 开发者_Go百科in chunks where every part is the string between 2 slashed. Now I'd like to have all the parts in 1 variable to work with.

For Example:

/de/my/page

de > language
my/page > 1 variable

Any ideas?


Advice from Hari K is the best choice, but if you really want to keep your slash, you can work with a Zend_Controller_Router_Route_Regex to catch your parameter, you just need to find a good regexp, a simple example :

$routetotry = new Zend_Controller_Router_Route_Regex('([^/]+)/(.*)',
                    array(1 => 'de', 'controller' => 'someController', 'action' => 'someAction'),
                    array(1 => 'lang',2=>'my_variable_with_slash'),
                    '%s/%s'
);

$router->addRoute('routetotry', $routetotry);


Custom router. Most flexible solution, but not the easiest one :(


Replace the slashes in the slug with someother value of your choice.

For example hyphen ( - ) or underscore ( _ ) .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜