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

Which Controller to extend in lieu of XenForo_Abstract

AndyB

Well-known member
#1

Chris D

XenForo developer
Staff member
#2
I can't see anything wrong with your code.

It's simple. There's two options:

1) Create a new route and create a new controller that extends XenForo_ControllerPublic_Abstract

If your board URL is http://xenforo.com/community and your new route is showdeleted, your URL will be http://xenforo.com/community/showdeleted.

2) Extend an existing controller using the XenForo Class Proxy system and load_class_controller code event.
PHP:
<?php

class Your_Controller_Name extends XFCP_Your_Controller_Name
This allows you to either modify existing actions within that controller or add new actions to the controller.

If your board URL is http://xenforo.com/community and you are extending the forum controller, and you're adding a new action called actionShowDeleted then your URL will be http://xenforo.com/community/forums/forum-name.1/show-deleted
 

AndyB

Well-known member
#3
Thank you, Chris.

So if I understand correctly, I should be able to extend XenForo_Abstract class as a XFCP?

PHP:
<?php

class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_XenForo_ControllerPublic_Abstract
...
 

Marcus

Well-known member
#4
class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_Andy_ShowDeleted_ControllerPublic_ShowDeleted
 

Chris D

XenForo developer
Staff member
#5
What I'm trying to say, Andy, is your current code is fine. There should be no reason to change it.
 

AndyB

Well-known member
#6
class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_Andy_ShowDeleted_ControllerPublic_ShowDeleted
Hi Marcus,

When I try that I get the following error:

An exception occurred: Cannot load class using XFCP. Load the class using the correct loader first. in /home/southbay/www/forums/library/XenForo/Autoloader.php on line 108
Listener.php

PHP:
<?php

class Andy_ShowDeleted_Listener
{
    public static function showDeleted($class, array &$extend)
    {
        $extend[] = 'Andy_ShowDeleted_ControllerPublic_ShowDeleted';
    }
   
    public static function loadClassModel($class, array &$extend)
    {
        $extend[] = 'Andy_ShowDeleted_Model_DeletionLog';
    }   
}

?>
The Code Event Listener:

pic001.jpg

ShowDeleted.php

PHP:
<?php

class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_Andy_ShowDeleted_ControllerPublic_ShowDeleted
{	
	public function actionIndex()
	{	
...
 

Chris D

XenForo developer
Staff member
#8
Yeah. But the key thing is, do you understand why?

I can't see anything wrong with your code.

It's simple. There's two options:

1) Create a new route and create a new controller that extends XenForo_ControllerPublic_Abstract

If your board URL is http://xenforo.com/community and your new route is showdeleted, your URL will be http://xenforo.com/community/showdeleted.

2) Extend an existing controller using the XenForo Class Proxy system and load_class_controller code event.
PHP:
<?php

class Your_Controller_Name extends XFCP_Your_Controller_Name
This allows you to either modify existing actions within that controller or add new actions to the controller.

If your board URL is http://xenforo.com/community and you are extending the forum controller, and you're adding a new action called actionShowDeleted then your URL will be http://xenforo.com/community/forums/forum-name.1/show-deleted