久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Zend 中的動作視圖助手 - 解決方法?

Action View Helper in Zend - Work around?(Zend 中的動作視圖助手 - 解決方法?)
本文介紹了Zend 中的動作視圖助手 - 解決方法?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在構建一個界面,我想將其用作選項卡式瀏覽"功能.這些選項卡中的每一個都已編寫為一個操作,選項卡式界面作為指向各個選項卡的鏈接工作正常.我決定嘗試為這個控制器編寫索引"頁面 - 將所有選項卡的內容放入隱藏的 div 并使用 jQuery 在它們之間交換,但是一旦我開始使用動作視圖助手 - 我遇到很多人說這是不好的做法.(見這篇文章)

其中一些操作會構建表單 - 從模型等中獲取一些數據以進行顯示.我希望每個操作都能繼續獨立運行(還有一些解析形式).

瀏覽到/item 應該會為您提供選項卡式菜單,以及隱藏標簽中的所有 div 內容 - 其中/item/tab2 是特定操作(例如表單提交).

另一個復雜性/警告 - 如果用戶無權訪問該選項卡",某些操作將引發訪問異常.我不想對系統進行兩次訪問檢查(從而顯示一個包含空內容的選項卡).

我只是想弄清楚處理這類事情的最佳實踐是什么,我認為可能是操作助手.如果我嘗試使用視圖助手 - 我開始懷疑這是否是組裝 Zend_Form 的正確位置.

有沒有人對不使用 Zend_View_Helper_Action 的正確"方法有任何建議?

解決方案

解決動作視圖助手的正確方法,正如我在您引用的文章中所述,是創建可直接訪問模型以獲取數據的部分他們需要.如果這會在您的視圖中涉及很多邏輯,則可以通過視圖助手(您自己制作;)).

動作視圖助手不僅受到性能問題的困擾,而且還會造成可怕的調試噩夢,如果您需要它,那么您的應用程序可能沒有遵循 MVC,因此,您正在使用控制器進行重用,而不是模式,即模式意圖.

您可以使用視圖對象的渲染或部分方法從布局或當前操作視圖中渲染部分.

如果您有多個操作來處??理來自選項卡的多個可能的帖子,那么您應該將所有這些操作設置為呈現相同的視圖腳本,然后該腳本將使用直接來自模型的數據呈現所有選項卡.

I'm working on building up an interface that I want to function as a "tabbed browsing" sort of function. Each of these tabs has already been written as an action and the tabbed interface works fine as links to the individual tabs. I decided to try writing the "index" page for this controller - putting the content of all the tabs into hidden divs and swapping between them with jQuery, but once I started to use the action view helper - I ran into a lot of people saying that its bad practice. (see this article)

Some of these actions build up forms - grab some data from the model, etc to display. I want each of the actions to continue to function on their own (some parse forms as well).

Browsing to /item should give you the tabbed menu, plus all of the div's contents in a hidden tag - where /item/tab2 is a specific action (form submit for instance).

Another complication/caveat - Some of the actions will throw Access Exceptions if the user doesn't have access to that "tab". I'd prefer not to build access checking into the system twice (thus showing a tab with empty content).

I'm just trying to figure out what the best practice is to handle this sort of thing, and I thought that the action helper might be it. If I try to use View Helpers - I start wondering if that is the right place to assemble a Zend_Form.

Does anyone have any suggestions on the "proper" way to work around not using the Zend_View_Helper_Action ?

解決方案

The Correct way to work around the action view helper, as I stated in the article you cited, is to create partials which access the model directly to fetch the data they need. This can be through a view helper (you make this yourself ;)) if this would involve a lot of logic in your view.

The action view helper is plagued with more than just performance issues, but also creates horrendous debugging nightmares, and if you need it, then your application is probably not following MVC, and therefore, you are using the controller for reuse, instead of the model, which is the patterns intention.

You can render partials from within your layout or current actions view with the render or partial methods of the view object.

If you have multiple actions to deal with multiple possible posts from your tabs, then you should set all of these actions to render the same view script, which will then render all of the tabs with data direct from the model.

這篇關于Zend 中的動作視圖助手 - 解決方法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Is this a good way to match URI to class/method in PHP for MVC(這是將 URI 與 PHP 中用于 MVC 的類/方法匹配的好方法嗎)
Where do I save partial (views) in Zend Framework, to be accessible for all Views in my App?(我在哪里保存 Zend Framework 中的部分(視圖),以便我的應用程序中的所有視圖都可以訪問?) - IT屋-程序員軟件開發技術
Having a single entry point to a website. Bad? Good? Non-issue?(有一個網站的單一入口點.壞的?好的?沒問題?)
Is MVC + Service Layer common in zend or PHP?(MVC + 服務層在 Zend 或 PHP 中常見嗎?)
Hello World example in MVC approach to PHP(PHP MVC 方法中的 Hello World 示例)
Separation of concerns; MVC; why?(關注點分離;MVC;為什么?)
主站蜘蛛池模板: 亚洲精品久久久久中文字幕欢迎你 | 99这里只有精品视频 | 天天摸天天干 | 国产精品一区在线观看 | 国产一级毛片视频 | caoporn国产精品免费公开 | 久久99国产精一区二区三区 | 国产99视频精品免视看9 | 四虎av电影| 欧美精品一区二区三区在线播放 | 久久夜夜 | 久久精品亚洲一区 | 日韩日韩日韩日韩日韩日韩日韩 | 欧美在线观看一区二区 | 久热精品在线播放 | 四虎成人免费视频 | 亚洲欧美视频 | 一区二区三区国产精品 | 国产成人精品久久二区二区91 | 人人干在线视频 | 日韩在线精品视频 | 精品亚洲一区二区三区 | 91亚洲视频在线 | 伊人手机在线视频 | 亚洲免费网 | 91精品国产91久久综合桃花 | 精品久久久久久久人人人人传媒 | 亚洲不卡| 亚洲综合在线一区二区 | 91一区二区在线观看 | 亚洲成av人影片在线观看 | 欧美一区二区久久 | 国内自拍偷拍 | 国产精品久久久久久 | 亚洲国产成人精品在线 | 日本成人免费观看 | 久久久久久久综合色一本 | 国产一级片免费在线观看 | 久久久久久成人 | 高清av电影 | 久久视频免费看 |