php - StackOverflow style routing with Zend Framework -


i'm building q&a site stackoverflow zend framework. it's set except fancy urls. urls should this:

wwww.site.com/programming/questions/321345/question-title-sanitized-with-dashes 

or

www.site.com/photography/questions/45621/photography-site-question 

but need site homepages like:

www.site.com/programming 

i think have use route chaining nice.

you can achieve quite using custom routes. since didn't specify how have structured code, i'm going make following assumptions:

  • your site has "sections" photography , programming found based on parameter
  • you have single controller handles questions sections, chooses based on parameters

first, homepage case:

route :section, , specify defaults module, controller , action handles section homepages.

second, question case:

route :section/questions/:id/:title, , again specify defaults module, controller , action handles specific questions. define title's default empty, because question can found based on id.

then, in controllers can use $this->_getparam('section') determine section should used, , on.

if don't know how create these routes, suggest peruse manual zend_controller_router , manual zend_application resources how define routes in application.ini


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -