1

I am trying to make a route in the ini file to match the following URLs, but I have been unsuccessful.

/add-announce.html
/add-announce-books-53.html

My route is this:

routes.add_announcement.type = "Zend_Controller_Router_Route_Regex"
routes.add_announcement.route = "/add-announce(-[a-zA-Z_]+)?(-[\d]+)?.html"
routes.add_announcement.defaults.module = announcement
routes.add_announcement.defaults.controller = frontend
routes.add_announcement.defaults.action = add
routes.announcements.defaults.catName = null
routes.announcements.defaults.catId = null
routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2

1 Answer 1

1

Maybe because your matches has '-' at the beginning?, Can you try with:

routes.add_announcement.route = "add-announce(?:-([a-zA-Z_]+))?(?:-([\d]+))?.html"

EDIT: I just found the error, you set the mapped values wrong:

routes.add_announcement.map.catName = 1
routes.add_announcement.map.catId = 2

instead you have to do it like this:

routes.add_announcement.map.1 = "catName"
routes.add_announcement.map.2 = "catId"

Also routes.announcements.defaults.catName shouldn't be routes.add_announcement.defaults.catName?

Sign up to request clarification or add additional context in comments.

6 Comments

Still fails (page won't load). Thank you for your response :)
@user1059855 I edited my answer.. try to remove the first "/"
tried removing it, adding backslash. Maybe the issue is somewhere else. Yet all the other normal routes work just fine :-|
@user1059855 check the new answer.
my bad when lacking "add_", it shouldn't affect the route anyway. Indeed, swapping the variable mapping made the page load (it seems that the zend manual is outdated as the mapping seems valid in the manual either way). Now to make it work. Cheers :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.