Lots of environmental information -- thanks, as it helps provided
context. However, as a result, I'm going to top-post to get right to the
heart of the issue: you never registered your custom view helper path.
You have the following line:
Zend_Controller_Action_HelperBroker::addPrefix('core_Helper_View');
but that's registering the prefix with the _ACTION_ helper broker, not
the view. You need to add the following line:
$view->addHelperPath('core/Helper/View/', 'core_Helper_View');
in your Initialize class' initView() method. I'd also remove that action
helper broker registration, as you almost certainly didn't intend for
that.
-- Bram Vogelaar <[EMAIL PROTECTED]> wrote
(on Wednesday, 06 August 2008, 10:59 AM +0200):
> Dear All
>
> I currently trying to get a view helper to work and as soon as i
> include a custom view helper in a view using <?= $this->MyNewViewHelper
> ?>
> the resulting rendered view is empty/blank. I would really appreciate if
> someone could shed some light on what i am doing wrong as I have tried
> to use v1.53, v1.6 RC1 and standard\branches\release-1.6. of the
> framework and I can t get any to work and no errors show up in the
> apache or php log.
>
> with regards
> Bram
>
> i am currently utilizing the following project layout on OS X 10.5.4
> using xampp 0.7.2 with /path/to/php, /path/to/pear, /path/to/Library and
> /path/to/application as included folders
>
> htdocs
> |-> index.php
>
> <index.php>
> require_once('Zend/Loader.php');
>
> Zend_Loader::registerAutoload();
>
> $front = Zend_Controller_Front::getInstance();
> $front->registerPlugin(new core_Initialize());
> $front->dispatch();
> </index.php>
>
> Library
> |->Zend
> application
> |->modules
> |->default
> |->controllers
> |->IndexController.php
> |->models
> |->views
> |>scripts
> |->index
> |->index.phtml
> |->core
> |->config
> |->tmp
> |->logs
> |->Acl
> |->Plugin
> |->Helper
> |>View
> |-> MyNewViewHelper.php
> |->Theme
> |->layout.phtml
> |->initialize.php
>
> <IndexContolller.php>
> class IndexController extends Zend_Controller_Action
> {
> public function indexAction()
> {
> $this->view->headTitle('Dashboard');
> }
> }
> </IndexContolller.php>
>
> <index.phtml>
> <h2>hello world</h2>
> </index.phtml>
>
> <layout.phtml>
> <?= $this->headTitle() ?>
> <?= $this->MyNewViewHelper() ?>
> <?= $this->layout()->content ?>
> </layout.phtml>
>
> <MyNewViewHelper.php> (which is a copy of Zend_View_Helper_Url)
>
> class core_Helper_View_MyNewViewHelper {
>
> public function url(array $urlOptions = array(), $name = null,
> $reset = false, $encode = true)
> {
> $router = Zend_Controller_Front::getInstance()->getRouter();
> return $router->assemble($urlOptions, $name, $reset, $encode);
> }
>
> }
> </MyNewViewHelper.php>
>
> <part of initialize.php>
>
> $this->_root = realpath(dirname(__FILE__) . '/../../');
>
> public function routeStartup()
> {
> $this->initHelpers();
> $this->initView();
> $this->initControllers();
>
> $this->_front->throwExceptions(false);
> }
>
> public function initHelpers()
> {
>
> Zend_Controller_Action_HelperBroker::addPrefix('core_Helper_View');
> }
>
> public function initView()
> {
> // Setup View
> $view = new Zend_View();
>
> // Set view in ViewRenderer
> $viewRenderer =
> Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
> $viewRenderer->setView($view);
>
> Zend_Layout::startMvc($this->_root . '/application/core/Theme');
> $request = Zend_Controller_Front::getInstance()->getRequest();
> }
>
> public function initControllers()
> {
> $this->_front->addModuleDirectory($this->_root . '/
> application/modules/');
> }
> </part of initialize.php>
>
--
Matthew Weier O'Phinney
Software Architect | [EMAIL PROTECTED]
Zend Framework | http://framework.zend.com/