Regex Route question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Regex Route question

Antonio Caccese-2
Hi, i have a routing problem in ZF v1.*

I'm creating an ecommerce site and i want the following routes for
categories:

/subcategory1
/subcategory1/subcategory2
/subcategory1/subcategory2/subcategory3
/subcategory1/subcategory2/subcategory3/../subcategoryN

I removed the default routes from FrontController and i've created this
regex route:

routes.categorie.type         = Zend_Controller_Router_Route_Regex
routes.categorie.route         = "([a-zA-Z-_0-9\/]*)\/([a-zA-Z-_0-9]+)"
routes.categorie.defaults.module   = catalogo
routes.categorie.defaults.controller = categorie
routes.categorie.defaults.action = view
routes.categorie.defaults.layout = sidebar
routes.categorie.map.1 = subCategories
routes.categorie.map.2 = categoryIdent
routes.categorie.reverse = /%s/%s

This route doesn't match the URL with only one category ( e.g. /category1 ).
Anyone can help me, or suggest a better solution?

Thanks in advance
Antonio
Reply | Threaded
Open this post in threaded view
|

Re: Regex Route question

renatomefidf
This post has NOT been accepted by the mailing list yet.
Try to change your regex to something like this:  "([a-zA-Z-_0-9\/]*)\./([a-zA-Z-_0-9]+)" or  "([a-zA-Z-_0-9\/]*)\/.([a-zA-Z-_0-9]+)" 
Maybe the problem is that you are implying a "/something/another" in your regex.

---------------------------------------------------------
Renato Mendes Figueiredo
(61) 9122-5946 ou (61) 3345-8648


On Mon, Jun 16, 2014 at 10:23 AM, Antonio Caccese-2 [via Zend Framework Community] <[hidden email]> wrote:
Hi, i have a routing problem in ZF v1.*

I'm creating an ecommerce site and i want the following routes for
categories:

/subcategory1
/subcategory1/subcategory2
/subcategory1/subcategory2/subcategory3
/subcategory1/subcategory2/subcategory3/../subcategoryN

I removed the default routes from FrontController and i've created this
regex route:

routes.categorie.type         = Zend_Controller_Router_Route_Regex
routes.categorie.route         = "([a-zA-Z-_0-9\/]*)\/([a-zA-Z-_0-9]+)"
routes.categorie.defaults.module   = catalogo
routes.categorie.defaults.controller = categorie
routes.categorie.defaults.action = view
routes.categorie.defaults.layout = sidebar
routes.categorie.map.1 = subCategories
routes.categorie.map.2 = categoryIdent
routes.categorie.reverse = /%s/%s

This route doesn't match the URL with only one category ( e.g. /category1 ).
Anyone can help me, or suggest a better solution?

Thanks in advance
Antonio



If you reply to this email, your message will be added to the discussion below:
http://zend-framework-community.634137.n4.nabble.com/Regex-Route-question-tp4662147.html
To unsubscribe from Zend Framework, click here.
NAML