Hey Aaron,

After taking a more critical look at your setup, it looks like I gave you incomplete advice. My apologies for this.

The PHP files that perform the processing should be stored in
  BASE_PATH . "/library/App/View/Helper/LoggedInAs.php"

The location of the files that perform the HTML output should be placed in
  APPLICATION_PATH . "/views/scripts/partials/loggedInAs.phtml"

These are known as view helper partial files. If you need to perform any HTML output, generate your array of data in the PHP file and pass the result of that as an array to the view partial. This will help you follow more closely the MVC pattern. In order to pass data to a partial and extract the HTML output, follow the example:

<?php

class App_View_Helper_Example extends Zend_View_Helper_Abstract
{
  // Let's assume $this->view was set in the __construct and contains
  // an instance of Zend_View.

  public function example($name, $value = null)
  {
    $data = array(
      'name' => $name,
      'value' => $value,
    );

    return $this->view->partial('partials/loggedInAs.phtml', $data);
  }
}

?>

On a side note, there is a more consolidated method of defining the location of the view scripts on a per-module basis:

resources.layout.viewBasePathSpec = APPLICATION_DIR "modules/:module/views"

The above line should go in your application.ini. This will be effective for each module you have and may create.

Finally, in your bootstrap, you will want to add the view helper prefix path so that Zend_View can load the PHP processor. Zend_Layout uses an instance of Zend_View to render the data, which is why it's looking for a *view* helper ;)

Add the following to your application/Bootstrap.php to add the prefix paths to your view helper:

<?php
    /**
     * Initializes the Views
     * @return Zend_View
     */
    protected function _initViews()
    {
        $this->bootstrap('layout');
        $view = $this->getResource('layout')->getView();
        $view->addHelperPath(
            'App/View/Helper',
            'App_View_Helper'
        );
    }

?>

This should get you on your way now :)

Hope this helps,
-Kizano
//-----
Information Security
eMail: [email protected]
http://www.markizano.net/

Reply via email to