1. 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

Discussion in 'XenForo Development Discussions' started by Chris D, Oct 16, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    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:
    [​IMG]

    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:
    [​IMG]

    What have I missed? :(
     
  2. cclaerhout

    cclaerhout Well-Known Member

    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)
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    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:
     
  4. Lawrence

    Lawrence Well-Known Member

    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']
            );
        }
    }
     
  5. Chris D

    Chris D XenForo Developer Staff Member

    You're right, I don't need it for the filter list to work...

    But look again...

    Here's my unfiltered list:
    [​IMG]

    Notice it has a view count and reset link?

    Look what happens now when I try to filter that list:
    [​IMG]

    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 :(
     
  6. Lawrence

    Lawrence Well-Known Member

    Can you post your template code?
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    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:
    [​IMG]
    Sorry for being so dumb and thank you both for your help.
     
    Lawrence and cclaerhout like this.
  8. oman

    oman Well-Known Member

    Looking great Chris! Well designed.
     

Share This Page