Route Regex - 2 Categories and html product page
1
2
3
4
56
7
8
| // route in config.ini
routes.products.type = "Zend_Controller_Router_Route_Regex"
routes.products.route = "products(?:/([a-z0-9_-]+)(?:/([a-z0-9_-]+)(?:/([a-z0-9_-]+).html)?)?)?"
routes.products.defaults.controller = "index"
routes.products.defaults.action = "routes"routes.products.map.1 = "kind"
routes.products.map.2 = "category"
routes.products.map.3 = "product" |
1
2
3
| //in bootstrap
$router = $this->_front->getRouter();
$router->addConfig($this->_config, 'routes'); |
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
| //use routesAction like this:
public function routesAction()
{
$kind_name = $this->_getParam('kind',0);
$cat_name = $this->_getParam('category',0); $prod_name = $this->_getParam('product',0);
if ($prod_name != FALSE){
$this->_forward('product');
}elseif($cat_name != FALSE){ $this->_forward('category');
}elseif($kind_name != FALSE){
$this->_forward('kind');
}else{
$this->_forward('allproducts'); }
} |
Comments
You must login before commenting on a snippet. If you do not have an account,
please register.
Snippet description
default
www.site.com/products/
go to allproductsAction
www.site.com/products/category/
go to kindAction
www.site.com/products/category/subcategory/
go to categoryAction
www.site.com/products/category/subcategory/product.html
go to productAction
Snippet details
- Created:
-
Mala
1 year ago
- Edited:
-
Mala
1 year ago
- Revision Id:
- 103
- Edit Message:
- Initial Release
- Tags:
- Route Regex
- Comments:
- 1
- Views:
- 163
- Points:
- 1 (1 votes)
History
1 year ago
Nice ;)