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

Extending member controller but no more profiles

A

account8226

Guest
#1
Hello,

I am following this tutorial by Kier, to extend member's controller (each member have to have a new custom page, that they can access via their profile url/newpagetesting for example).

So http://forum/members/1/newpagetesting would bring to the new page (empty for the moment) and http://forum/members/1/ would bring anyone to the normal profile from the xenforo core.

My problem is that when I want to load the normal profile, it brings me to the extended class I made, with the empty template.

I have my Public controller :
PHP:
<?php
class A_ControllerPublic_Test
    {
        public function actionIndex()
        {
            $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
            $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
 
            return $this->responseView(
                'Dev_ViewPublic_Member_Title', 'custom_profile',
                array('user' => $user)
            );
        }
    }
?>
And here is my LoadClassController :
PHP:
<?php
class A_Listener_LoadClassController
{
    public static function extendMemberController($class, array &$extend)
    {
        if ($class == 'XenForo_ControllerPublic_Member')
        {
            $extend[] = 'A_ControllerPublic_Test';
        }
    }
}
I created the listener.

Best regards.
 

Jake Bunce

XenForo moderator
Staff member
#2
You need to use the XFCP class:

Code:
<?php
class A_ControllerPublic_Test extends XFCP_A_ControllerPublic_Test
    {
        public function actionIndex()
        {
            $userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
            $user = $this->getHelper('UserProfile')->assertUserProfileValidAndViewable($userId);
 
            return $this->responseView(
                'Dev_ViewPublic_Member_Title', 'custom_profile',
                array('user' => $user)
            );
        }
    }
?>
And note that you are overriding the existing actionIndex() with your extended class. That will replace the member list. Kier's example was to create a new action that doesn't already exist. You can do either, I just question your decision to override actionIndex().
 
A

account8226

Guest
#3
Thanks for the awnser Jake, I was stupidly overwritting the index action, just had to create an other action called title, and everything is working then ;)

Really appreciate your help.