iếp theo tạo các phương pháp deleteAction () trong MenuItemController. Hành động này sẽ tạo ra một thể hiện mới của mô hình MenuItem và tìm thấy những mục trình đơn phù hợp với ID đã được thông qua để hành động trong các tham số URL. | CHAPTER 7 CREATING THE SITE NAVIGATION Next create the deleteAction method in the MenuItemController. This action will create a new instance of the Menuitem model and find the menu item that matches the ID that was passed to the action in the URL parameter. Next it runs the deleteItem method. Then it sets the menu parameter and forwards to the indexAction method. Listing 7-46 shows the complete method. Listing 7-46. The deleteAction Method in application controllers public function deleteAction id this- _request- getParam id mdlMenuItem new Model_MenuItem currentMenuItem mdlMenuItem- find id - current mdlMenuItem- deleteItem id this- _request- setParam menu currentMenuItem- menu_id this- _forward index Rendering Menus Now that the menu management component is complete you are ready to render the menus. To do this create a new action in the MenuController named renderAction . You can do this with Zend_Tool as shown in Listing 7-47. Listing 7-47. Creating the Render Menu Action with Zend_Tool zf create action render menu Zend_Navigation is a new component that has been developed to make managing your site navigation as easy as possible. To use Zend_Navigation you need to first fetch all items from the requested menu. Then load each of those items into an array. When this is complete you create a new instance of Zend_Navigation which you pass the array to. Finally you pass this to the Zend_View navigation helper as shown in Listing 7-48. Listing 7-48. TherenderAction Method in application controllers public function renderAction . menu this- _request- getParam menu mdlMenuItems new Model_MenuItem menuItems mdlMenuItems- getItemsByMenu menu if count menuItems 0 foreach menuItems as item label item- label if empty item- link uri item- link else uri page open id . item- page_id 138 Download at CHAPTER 7 CREATING THE SITE NAVIGATION itemArray array label label uri uri . container new Zend_Navigation itemArray this- .