0

This question is related to the question asked here, regarding the best practice for handling tabbed interfaces. It made reference to a blog post titled, Why the Zend Framework Actionstack is Evil, which outlined that you should use partials and view helpers for elements that will be reused. This is fine until the element has to handle some input, in which case view helpers are not the answer. This is where you use action helpers, Matthew Weier O'Phinney talks about a use case for this in his blog post titled, Using Action Helpers To Implement Re-Usable Widgets.

After reading these viewpoints I seem to be more confused on the best course of action for my interface. The site will consist of three major tabs, Cases, Staff, & Departments. Each of these tabs will follow a similar layout consisting of a selector/search table, a (Case|Staff|Department) summary, and then another area with vertical tab menu. The main tabs will have some vertical tab items that are identical except for the information being displayed.

The question is how do I structure the views, helpers and controllers around this interface. I was thinking of having an index, case, staff and department controller. Creating an action helper which will reuse a view for each major tab, but use the request data to determine the currently selected (Case|Staff|Department). Using the individual tab controllers to handle jQuery ajax requests for the vertical tab content and delegate the output to a view helper which will reuse a common view. And also use the individual tab controllers to handle jQuery ajax crud operations.

Is this the best way to do this, or are there better more efficient methods?

Community
  • 1
  • 1
Rod
  • 33
  • 4

1 Answers1

1

I'd create separate controllers for each of your three main tabs. The vertical tabs you describe would correspond to actions on those controllers.

For rendering all those navigation tabs - top-level and the verticals - it sounds like the answer is.... Zend_Navigation (more info).

You can place all the structured navigation data - probably read from a INI file or from an XML file or even from a structured array - into a single Zend_Navigation container and then render the "active" branch.

David Weinraub
  • 14,144
  • 4
  • 42
  • 64
  • Thankyou for you prompt reply. This is exactly what I have done so far, but what I am concerned about is that I have the same design for the main tabs but have three different views for them. And for the verticals, which are accessed by ajax, they also use the same design but use different views. To maintain the practice of having fat models and skinny controllers shouldn't I build reusable helpers (view|action) for the rendering and managing of these views? – Rod Nov 25 '10 at 04:06
  • I'd use 1 action for all the tabs , and then in the view use partials to render each tab content ( so that when you change the tab you don't have to reload the page ) , allso as mentioned by David use Zend_Navigation to display the tabs , to keep the controller skinny you can move most of the tab data building inside a model under 3 different methods ( one for each tab , or eaven more if part of the code will be reused on other parts of you're app ) tough i don't know how this will affect the performance but it will improve the user experience . – Poelinca Dorin Nov 25 '10 at 06:18
  • I see @poelinca's point: perhaps a single controller w/ 3 actions. Each action can perform all the tasks required to populate the vertical tabs. Then some cool client-side stuff so that you can see it all without a page reload. But I think your question is more than that. These three "pages" sound "structurally" similar: search table, summary, tabs. So, it seems reasonable to try to create an action helper that's parameterizable enough to "get" the req'd data (search table, summary, etc) and then use a similarly parameterized view-helper and partials for rendering. If it truly is that similar. – David Weinraub Nov 25 '10 at 11:15
  • I am now rendering the tabs using zend navigation (ZN) and the tab content is being rendered in a partial loop using data defined in the index controller. The vertical tabs are being rendered by ZN and the tab content is being rendered by reusable view helpers. jQuery will switch between the content, before it switches it will check the server for a more current version of the content to load. Operations to affect data will be displayed in a modal window and use controllers, eg new client will go through a client controller, edit staff through staff controller, etc. Thanks for the help. – Rod Nov 29 '10 at 22:20
  • Glad I could be of some help. ;-) – David Weinraub Dec 02 '10 at 14:33