Question : Trying to add Zend View Helper but get error Plugin by name not found in registry

What am I doing wrong?

I'm trying to add a custom view helper so that I can run a simple function in Zend in controllers and views. I am trying to take the title of a video and hyphenate it so that I can pass cleanly into the URL.

I added this to my config.ini:
resources.view[] =

I added this to my Bootstrap.php file:
$view->addHelperPath('My/View/Helper', 'My_View_Helper');

I added this to my layout:
<?=$this->preparforurl($asset->title)?>

I added the first code below in a file name Prepareforurl.php to /My/View/Helper/

Why does Zend not see my plugin? What am I doing wrong? Any help much appreciated...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
//  /My/View/Helper/Prepareforurl.php

<?php

class My_View_Helper_Prepareforurl extends Zend_View_Helper_Abstract
{
	
	public function prepareforurl($item) {
		// set and remove bad characters
		$badChars = '#[^-a-zA-Z0-9_ ]#';
		$item = preg_replace($badChars, '', $item);
		$item = trim($item);
		// change all dashed, underscores, spaces to dashes
		$item = preg_replace('#[-_ ]+#', '-', $item);
		return $item;
	}

}

?>

Answer : Trying to add Zend View Helper but get error Plugin by name not found in registry

Ok your code is good but you have to insert your helper under Library path and your view_helper path.

Ex:

In your index.php (startup for ZF):

define('ROOT_DIR', dirname(dirname(__FILE__)));
define('LIB_DIR', ROOT_DIR . DS . 'Library');


set_include_path('.'
    . PS . LIB_DIR
    //... any you want
    . PS . get_include_path()
);

Your view_helper path is:

<root>/Library/My/View/Helper/Prepareforurl.php

Random Solutions  
 
programming4us programming4us