Zend Framework - long routes(Router)
I'm already thinking about to start using simple GET string.
Or I'm not so good at configuring routes? :)
And configuring routes via regex in .htaccess
foreach($links as $a)
{
$Router->addRoute($a['link'],
new Zend_Con开发者_JAVA技巧troller_Router_Route(
$a['link'] . '/:page/:ad_id/:photo/:price_from/:price_to/:regions/:rajoni/:towns/:pagasti/:gadi_from/:gadi_to/:augums_from/:augums_to',
array
("page" => 1,
"ad_id" => 0,
"photo" => 0,
"price_from" => 0,
"price_to" => 0,
"regions" => 'def',
"rajoni" => 'def',
"towns" => 'def',
"pagasti" => 'def',
"gadi_from" => 'def',
"gadi_to" => 'def',
"augums_from" => 'def',
"augums_to" => 'def',
"department" => $a['department'],
"category" => '',
"link" => $a['link'],
"controller" => "ads",
"action" => "view",
)));
}
Please help me to find a right way to use Zend Framework Routes
After edit:
By the way, is it ok to loop through categories to bind route to them? So urls could be human readable?
Or better to stick to .htaccess file configuration? But I still didn't figured out, how to make human readable urls without adding number for categories to regex.
RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/page-([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2&Page=$3 [L]
RewriteRule ^.*-d([0-9]+)/.*-c([0-9]+)/?$ index.php?DepartmentId=$1&CategoryId=$2 [L]
The only way I have figured out, is to pass actual name of category as value and on server side compare it with array of category names.
Or there is a better way?
Are you using this route to show results of a search? If that's the case, I would strongly recommend avoiding routes of this length - they're harder to maintain (try adding another parameter) - use a GET query string as normal.
Structure something like /ads/view/:page/?ad_id=xxx&...
精彩评论