The quest of routing in Zend Framework

I am a ZF beginner and I am trying to find out a way to handle routing.

Let say that I am building a website with different sections:

http://example.com/news
http://example.com/articles
http://example.com/gallery
http://example.com/forum

I am wondering how should I set up routing? Take the forum as an example.

Let say I use this principle:

http://example.com/module/controller/action?var1=value&var2=value

And apply the principle to the forums function addpost:

"http://example.com/forum/addpost" should be routed to Forum module, viewthread Action, indexAction() method

The indexAction method displays a form where you can write your post. The forms action is pointing to http://example.com/forum/addpost/add
 which is represented by the addAction() method in the same controller.

By choosing module/controller/action route pattern, each controller manages a complete "forum function" like:

  • Adding a post (writing, preview, adding post)
  • Editing a post (writing, preview, update post)
  • Reading a post (display)

This looks like a good solution for me? But is it working?

And how can you handle a form which has several submit buttons in the above context? I must point the forms action to a *Action method in the Controller and inside this method I must handle which button the user has pressed and do a second "dispatch" on my own? I would like to have organized code, with one method per "subfunction". Has ZF built in functions for this?

/Erik


Posted

in

,

by

Tags: