English 中文(简体)
如果有观点,则严格检查――不工作
原标题:Zend check if view exist - class does not work

I have found this class:

https://github.com/lloydwatkin/Demos/blob/master/zendframework/renderifexists/RenderIfExists.php”rel=“nofollow”>https://github.com/lloydwatkin/Demos/blob/master/zendframework/renderifexists/RenderIfExists.php

守则认为:

    <?php
/**
* View helper to render a view file if it exists
*
* @author Lloyd Watkin
* @since 12/12/2010
* @package Pro
* @subpackage View
*/

/**
* View helper to render a view file if it exists
*
* @author Lloyd Watkin
* @since 12/12/2010
* @package Pro
* @subpackage View
*/
class Pro_View_Helper_RenderIfExists
    extends Zend_View_Helper_Abstract
{
    /**
* Errors
*
* @var string
*/
    const INVALID_FILE =  Invalid file parameter ;

    /**
* Holds file name for processing
*
* @var string
*/
    protected $_file;

    /**
* Takes a products options array and converts to a formatted string
*
* @param string $file
* @return string
*/
    public function renderIfExists($file)
    {
        if (!is_string($file) || empty($file)) {
            throw new Zend_View_Exception(self::INVALID_FILE);
        }
        $this->_file = $file;
        if (false === $this->_fileExists()) {
            return   ;
        }
        return $this->view->render($file);
    }

    /**
* Check to see if a view script exists
*
* @return boolean
*/
    protected function _fileExists()
    {
        $paths = $this->view->getScriptPaths();
        foreach ($paths as $path) {
            if (file_exists($path . $this->_file)) {
                return true;
            }
        }
        return false;
    }
}

如果存在某种观点,我想加以检查;如果是的话,则:

我将档案放在我/图书馆。 当我打电话1美元“&”;renderIfExists(Info- Box.phtml);我从控制者那里发现这一错误:

Message: Method "renderIfExists" does not exist and was not trapped in __call() 

How can I fix this? Thanks in advance!

最佳回答

您应使用:

问题回答

很晚,但你前面的法典是我写的。 如果框架知道如何装上档案,你是否登记了帮助者的道路?





相关问题
Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

PHP Framework: Ebay Like Site

I am going to be builiding a site like ebay - with all the features of ebay. Please note my payment method is limited to paypal. What would be the best PHP framework to use to build this quickly, ...

Link to a specific step in onepage checkout

Is it possible to redirect the browser to nth step in the onepage checkout? If so, how would one go about doing it? I m working on a payment module and have a sort of "cancel" action that i would ...

Tagging with Zend Framework

I m trying to create the same solutions as below, but using a simple MySQL query (instead of the static version used below where the words/tags are implemented in the code). The name of the MySQL ...

dynamicaly adding textboxes to zend_form

I hope that this is a quick question to answer. I am developing a form using Zend_Form, I have a number of Zend_Dojo_Form_Element_Textboxs to add to this form dynamically. These are added from rows ...

热门标签