Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-14-2008, 07:55 PM
dele454's Avatar
Member
 
Join Date: Jun 2008
Posts: 48
Default Custom View Helpers

I am having this issue of ZF locating where my custom View Helper classes are. The only way my view helpers work is when I include them in the Zend_View_Helper path - which ideally, I don’t want to do.

So I have a plugin folder in my library folder (apps>lib>Addon)

In this folder I have my folders as required (View & Helper folders)

For the view helper class I have done what is required ( TitleCasing the helper class name, prefixing the class name with the plugin folder path to the view helper folder & camelCasing the helper function name)

In my bootstrap included a path to where my view helper folder. And In my view script I made a function call to this helper function but on preview my page just appears blank.  It is only displays when I move the view helper class to Zend_View_Helper as mentioned above!

I am having similar problems with adding custom plugins too. ZF cant seem to resolve the path in these two cases. I have tried all sorts.

I came across this article( Zend_View helpers in include path) and I just want to know if you will recommend the route this guy suggests on solving this and if this behavior of the Zend_View is still true with the v1.5?


How can i get Zend_View to see my custom folders??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-14-2008, 10:32 PM
Senior Member
 
Join Date: Jun 2008
Location: Florida
Posts: 108
Default

You need to tell Zend_View where your helpers are, following your example (assuming your library is on drive w:\, for the sake of the example):

Code:
// instantiate the view and save Zend_View object to a variable
$view = new Zend_View();

// add to the helper path
$view->addHelperPath('W:\library\Addon\View\Helper', 'Addon_View_Helper');

$renderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$renderer->setView($view);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-15-2008, 08:09 AM
dele454's Avatar
Member
 
Join Date: Jun 2008
Posts: 48
Default

Quote:
Originally Posted by jweber View Post
You need to tell Zend_View where your helpers are, following your example (assuming your library is on drive w:\, for the sake of the example):

Code:
// instantiate the view and save Zend_View object to a variable
$view = new Zend_View();

// add to the helper path
$view->addHelperPath('W:\library\Addon\View\Helper', 'Addon_View_Helper');

$renderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$renderer->setView($view);

I did all that before i posted this post. I tried a full path to the directory too but nothing still.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-15-2008, 12:14 PM
Senior Member
 
Join Date: Jun 2008
Location: Florida
Posts: 108
Default

Perhaps you can post the code from your index.php here so we can take a look at it. If the helper works when placed in the Zend library that suggests to me that it is not an issue with the naming of the class or its methods, but rather with making it available to Zend_View via the addHelperPath() method.

I assume you have the entire library directory in the PHP include path...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-15-2008, 01:00 PM
dele454's Avatar
Member
 
Join Date: Jun 2008
Posts: 48
Default

Quote:
Originally Posted by jweber View Post
Perhaps you can post the code from your index.php here so we can take a look at it. If the helper works when placed in the Zend library that suggests to me that it is not an issue with the naming of the class or its methods, but rather with making it available to Zend_View via the addHelperPath() method.

I assume you have the entire library directory in the PHP include path...

Indeed i do i will post the code from index.php as well as a snapshot of my folder structure. Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-15-2008, 01:21 PM
dele454's Avatar
Member
 
Join Date: Jun 2008
Posts: 48
Default

Apache httpd.conf include path

Code:
php_value include_path ".;C:/xampp/htdocs/xampp/mainevent/apps/lib;C:/xampp/php/PEAR;C:/xampp/htdocs/xampp/mainevent/apps;C:/xampp/htdocs/xampp/mainevent/apps/modules/admin/views/forms;"

Index.php file:

Code:
<?php
require_once 'Bootstrap.php';

Bootstrap::run();
?>

Bootstrap.php file:

Code:
<?php

require_once 'Zend/Loader.php';
require_once 'Zend/Session.php';


class Bootstrap{

       public static function run()  {
           ...

           self::prepare();

           ...
       }

   public static function prepare() {
        self::setupController();
        self::setupView();
    }

public static function setupView() {

        $view = new Zend_View;
        $prefix = 'Addon_View_Helper';
        $config = Zend_Registry::get('config');
        $dir = $config->paths->data . '/lib/Addon/View/Helper';// from config file: C:/xampp/htdocs/xampp/mainevent/apps
        $view->addHelperPath($dir,$prefix);
		
        $view->setEncoding('UTF-8');
        $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
        Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
    }
Folder Structure:




Custom View Helper:
Code:
<?php 

class Addon_View_Helper_DateFormat {
		
         public function dateFormat($date="") {
         	
			$pieces = explode("-",$date,3);
			$newDate = $pieces[2] . "/" . $pieces[1] . "/" . $pieces[0];
            return $newDate;
         }

}
?>
Settings.ini file:

Code:
[development]

paths.base          = C:/xampp/htdocs/xampp/mainevent
paths.data          = C:/xampp/htdocs/xampp/mainevent/apps
paths.modules.admin = C:/xampp/htdocs/xampp/mainevent/apps/modules/admin
paths.templates = C:/xampp/htdocs/xampp/mainevent/templates
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-16-2008, 09:03 PM
dele454's Avatar
Member
 
Join Date: Jun 2008
Posts: 48
Default

Any one with help still???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-17-2008, 12:05 AM
Webstractions's Avatar
Junior Member
 
Join Date: Jul 2008
Posts: 2
Default

(sorry, bad advice)
__________________
Ronnie T. Dodger
Webstractions Web Development

Last edited by Webstractions : 07-17-2008 at 12:26 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:53 PM.