• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

ControllerAdmin responseView rendering the wrong view

Chris D

XenForo developer
Staff member
#1
I have created a new action in an extended controller (I have extended XenForo_ControllerAdmin_User). My new action is called actionProfileViews.

ProfileViews displays a list of users. I have created my own template for this (profile_views_user_list) but essentially it is the normal user_list template with a few customisations.

Well, here it is:


For each user, the template profile_views_user_list_items is included.

As you can see I have also included the standard functions for filtering a list.

This is my problem.

My action returns this:
PHP:
return $this->responseView('ProfileViewCount_ViewAdmin_List', 'profile_views_user_list', $viewParams);
ProfileViewCount_ViewAdmin_List looks like this:

PHP:
<?php

class ProfileViewCount_ViewAdmin_List extends XenForo_ViewAdmin_Base
{
	public function renderJson()
	{
		if (!empty($this->_params['filterView']))
		{
			$this->_templateName = 'profile_views_user_list_items';
		}

		return null;
	}
}
This should make it so that when the filter is used, the profile_views_user_list_items template is rendered.

Well, it doesn't do that :(

Instead it renders the default user_list_item as defined in XenForo_ViewAdmin_User_List:


What have I missed? :(
 

cclaerhout

Well-known member
#2
Everything looks correct. Can't you try to debug doing a dump of the $this->_templateName variable inside the conditional, and then see inside the firebug console the result? (it's just an idea)
 

Chris D

XenForo developer
Staff member
#3
Yeah this is really weird o_O

No output whatsoever. If I put a deliberate syntax error in my ViewAdmin class then I get an error telling me so.

Yet, Zend_Debug::dump($var), echo $var - literally anything has no affect whatsoever.

To make things even more frustrating, even though my responseView is clearly calling my custom class, if I attempt to debug code within the original XenForo class, I get an output :mad:
 

Lawrence

Well-known member
#4
You do not need this for the filter list to work:

PHP:
<?php
 
class ProfileViewCount_ViewAdmin_List extends XenForo_ViewAdmin_Base
{
public function renderJson()
{
if (!empty($this->_params['filterView']))
{
$this->_templateName = 'profile_views_user_list_items';
}
 
return null;
}
}
Try renaming that file for testing so XF can not find it, but still use this:

Code:
return $this->responseView('ProfileViewCount_ViewAdmin_List', 'profile_views_user_list', $viewParams);
The only time I have actually created a viewAdmin file was to render the Admin Options HTML so I could display the Options on my roster list template, the filtering of items still work as expected:

Code:
<?php
 
class IcewindDaleRP_Roster_ViewAdmin_Roster_List extends XenForo_ViewAdmin_Base
{
    public function renderHtml()
    {
        $this->_params['renderedOptions'] = XenForo_ViewAdmin_Helper_Option::renderPreparedOptionsHtml(
            $this, $this->_params['options'], $this->_params['canEditOptionDefinition']
        );
    }
}
 

Chris D

XenForo developer
Staff member
#5
You're right, I don't need it for the filter list to work...

But look again...

Here's my unfiltered list:


Notice it has a view count and reset link?

Look what happens now when I try to filter that list:


My filtered results no longer have a view count or reset link. It is now the default list item (from the user list) and that is defined in XenForo_ViewAdmin_User_List. I therefore need my add-on to use a custom class, but it is that which is being ignored :(
 

Chris D

XenForo developer
Staff member
#7
I...

I've just noticed something... :cautious: :oops:

Well... doh!

Can you post your template code?
Yes, I could... and when I started doing so I noticed:
Code:
<xen:form action="{xen:adminlink users/list, '', '_params={$linkParams}'}" ...
:rolleyes:
Of course users/list will return the original ViewAdmin class for the users list which loads the normal users list item.
I changed the form action to my Controller action et voila:

Sorry for being so dumb and thank you both for your help.
 

oman

Well-known member
#8
I...

I've just noticed something... :cautious: :oops:

Well... doh!


Yes, I could... and when I started doing so I noticed:
Code:
<xen:form action="{xen:adminlink users/list, '', '_params={$linkParams}'}" ...
:rolleyes:
Of course users/list will return the original ViewAdmin class for the users list which loads the normal users list item.
I changed the form action to my Controller action et voila:

Sorry for being so dumb and thank you both for your help.
Looking great Chris! Well designed.