Extending member controller but no more profiles

  • Thread starter Thread starter account8226
  • Start date Start date
A

account8226

Guest
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.
 
You need to use the XFCP class:

Rich (BB 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().
 
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.
 
Back
Top Bottom