Which Controller to extend in lieu of XenForo_Abstract

AndyB

Well-known member
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
 
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
...
 
class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_Andy_ShowDeleted_ControllerPublic_ShowDeleted
 
What I'm trying to say, Andy, is your current code is fine. There should be no reason to change it.
 
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.webp

ShowDeleted.php

PHP:
<?php

class Andy_ShowDeleted_ControllerPublic_ShowDeleted extends XFCP_Andy_ShowDeleted_ControllerPublic_ShowDeleted
{	
	public function actionIndex()
	{	
...
 
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
 
Extending default XenForo files = use Proxy System
Making new files (custom datawriter, model, controller) = don't
 
Thank you, Daniel.

It's wonderful when things are explained. Now it makes perfect sense.
 
Top Bottom