我在ZF 1.12.x項目的工作,我將保存在新的自定義幫助:/application/views/helpers/MyFormText.php
(也試圖與名稱View_Helper_MyFormText
):在Zend Framework 1中註冊自定義助手的正確方法是什麼?
助手的內容至今也很簡單:
class MyFormText extends Zend_View_Helper_FormText
{
public function MyFormText($name, $value = null, $attribs = null)
{
// @TODO: check if the component can be rendered on the view
return parent::formText($name, $value, $attribs);
}
}
當我訪問我這個錯誤結束頁:
[message:protected] => Plugin by name 'MyFormText' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:./../application/views/helpers/
是奇怪的,顯然這條道路:
Zend_View_Helper_: Zend/View/Helper/:./../application/views/helpers/
用於尋找幫助者,但即使該類無法加載。我已閱讀並嘗試了所有的這些:
- Zend Framework Create Custom View Helper?
- How to add a view helper directory (zend framework)
- how to register new helper (custom helper) in zend framework
- Zend: Where/how can I register custom view helpers?
我做錯了嗎?任何人都可以給我一些幫助嗎?我被卡住了
嘗試打印輔助路徑/ s。從視圖來看,你可以var_dump($ this)。你可以使用'Zend_View :: addHelperPath'註冊路徑。 – Progrock
@Progrock我沒有看到加載的路徑,所以可能沒有註冊。儘管我可以在Zend_View_Helper_:Zend/View/Helper /:./../ application/views/helpers /'錯誤處看到它。你能爲我寫一個小例子嗎? – ReynierPM
在application.ini - >'resources.view.helperPath.Your_View_Helper_Class_Prefix = APPLICATION_PATH「/ views/helpers」' – Progrock