This video covers how to setup and user Zend View Helpers. I also cover how state is managed within the class. Next week I’ll show you how you can use this technique with a bit of AJAX to make those View Helpers shine! I’ll post the project code for both videos with part 2.
Introducing Zend View Helpers
Description
This video covers how to setup and user Zend View Helpers. I also cover how state is managed within the class. Next week I’ll show you how you can use this technique with a bit of AJAX to make those View Helpers shine! I’ll post the project code for both videos with part 2.
Tags
AJAX, bootstrapping, HTML / CSS, jquery, view helpers

Your article is very usefulness. Can you please post some additional information about this? take care
Hi,
very very well done webcasts. Love them.
Im struggling with a problem though:
I have a helper that should show the usual “Welcome Guest!” or “Logged in as [user]” in my application. The problem is that I need to pass the identity object to the helper before it is being used in the layout. In other words, I have no idea how to “initialize” my helper so that it knows who is or is not currently logged in.
Thanks a bunch.
I’ll be glad to know the answer.
Hi Slavic, I think a singleton strategy would work for this, where you create a class that “owns” that little bit of data. Ideally it would be connected to Zend_Acl and you could just query Zend_Acl’s methods to get the answer for who’s logged in. I did an example like this a couple months back. Hope that helps!
Hi Jon,
thanks – I don’t yet use Zend_Acl, I use only Zend_Auth so i might need to read first about the acl features.
However, I fixed my problem by accessing Zend_Auth in the very view helper class, which I think is pretty much what you meant.
Thanks again.
Hey jon!
Can you explain why are you not putting helper files under application/views/helpers?
I tried to follow you with that folder structure, but just ended up with bunch of errors.
I ended up puting Notice.php in application/views/helpers folder and calling that class Zend_View_Helper_Notice and i managed to get everything to work.
Thanks for these screencasts!
Jon rocks my socks!
Hi there!
Nice screencast! Just one question. I’ve tried to use JQuery controls into layouts (not in the view scripts) but I don’t know why it doesn’t work. Could anybody help me with that?
Thanks a lot
another great tutorial, Thanks a lot. I tried this with jquery autocomplete “Custom data and display” example (only to get key/value feature)which shown in http://bit.ly/addWR0 to get key/value selection. First I tried it simply on form with static array.It worked
$formElement->setJQueryParams(array(‘source’ => array(
array(‘value’=>’NY’,'label’=>’New York’),
array(‘value’=>’BLN’,'label’=>’Berlin’),
array(‘value’=>’BTN’,'label’=>’Boston’)
)));
Then I tried with dynamic data with databases. In here I implement an array of arrays (value=>, label=>) and I add this to form element
$formElement->setJQueryParam(‘source’,'/admin/book/book-list’); //the url to get array object
but I don’t know how to send the array of arrays (value=>, label=>) as ajax response via json from action file.
I wrote this on action, but it not worked
$this->_helper->json(array_values($bookList));
I will be glad if anyone can help to fix this to me.
thanks again for zendcasts series, It’s really helpful to me
I added this to action. don’t know that it’s a proper way, but it works
$this->_helper->json($bookList->toArray());
thanks again for this series
The Site Looks amazing !! Great touch-up Jon
for those of you who get application error enter this in the production part of the application.ini file:
resources.view.helperPath.App_View_Helper = “App/View/Helper”
resources.view.helperPathPrefix.App_View_Helper = “App_View_Helper”
Why are you creating html in a string. I thought MVC practices dictated that html is only generated in views .phtml files.
Are view helpers an exception to this where it’s best practice to embed html in a string? If so how much html should you embed in strings in the helper and at what point do you move that html to a .phtml view?
hi,
Can anyone tell me where the link for part 2 to this tutorial is?
Cheers,
Steve