Trouble Understanding Custom Template-Controller Relationship


Well-known member
I'm creating a custom search page for my Resource Manager. I have built a custom controller to fetch the results, and currently outputs them using the resource_featured template, like so:
return $this->responseView('XenResource_ViewPublic_Resource_Featured', 'resource_featured', $viewParams);
I want to customize that output using my own template, but I don't understand exactly what this responseView() method is doing. There is no file located at /library/XenResource/ViewPublic/Resource/Featured.php as I had expected from the first parameter there.

While experimenting, I have also tried copy-pasting the contents of resource_featured into my own new custom template and just swapping out the names for the second parameter, but none of the dynamic elements in the template appear to be processed or output, which makes it clear to me I don't really understand what is going on here.

What does responseView() do, exactly? How can I wire up my own custom template to work with my new controller?
Last edited:
I really don't understand the choice for allowing a class not to exist, as I had the same WTF moment when I started writing public controllers.

It seems the rule of thumb is to write it in as if you are going to use a custom one. Then, at some point in the future when you want to add one, you don't need to change your code.

Just add a new class, and define a renderHtml() method that manipulates $this->_params for whatever view logic you want to to enhance.

Jeremy P

Well-known member
I think the choice was probably made to reduce boilerplate so you don't have to write empty view classes, and as you say it makes it easier should you want to add one in the future.


Well-known member
Hmm... OK. Some extensive documentation sure would be handy right now. I still feel pretty lost.

So what view class is rendering the "Featured Resources" page now?
It seems that writing

$this->render('template_name', $params);
is much less boilerplate code, and much more clear than having to (being able to) specify something that doesn't exist.


So what view class is rendering the "Featured Resources" page now?
Your template is just being rendered as-is. All the custom view classes do is let you modify the $params without having crazy templates, or lots of template-related logic added to your controller. It's nice for adding secondary data, or doing some last minute transformations that may be a little too advanced for template helpers.

The important thing is that it's optional.