XF 2.2 Help with extending XFCP_Thread.

Sivoph

Member
Hello. I'm looking to extend the XFCP_Thread dummy class, but I'm having issues:

Page view:

HTML:
Template Compilation Error
public:widget_new_posts - Class 'Nash\Noob\XF\Pub\Controller\XFCP_Thread' not found in /home/[redacted]/public_html/src/addons/Nash/Noob/XF/Pub/Controller/Thread.php:5


Callback:

HTML:
<xf:callback class="Nash\Noob\XF\Pub\Controller\Thread" method="actionPreview" params="['$params']"></xf:callback>

PHP:

PHP:
<?php

namespace Nash\Noob\XF\Pub\Controller;

class Thread extends XFCP_Thread
{

public function actionPreview(ParameterBag $params)
{

extensionhint.php:

PHP:
<?php

// ################## THIS IS A GENERATED FILE ##################
// DO NOT EDIT DIRECTLY. EDIT THE CLASS EXTENSIONS IN THE CONTROL PANEL.

namespace Nash\Noob\XF\Pub\Controller
{
    class XFCP_Thread extends \XF\Pub\Controller\Thread {}
}

Class extension:

1629639511237.png


This is an add-on with the directory: /home/[redacted]/public_html/src/addons/Nash/Noob/XF/Pub/Controller/Thread.php.

Does anyone know why I can't find the coveted XFCP_Thread? I don't want to use XF/Pub/Controller/Thread directly for future add-on compatibility. Also, to put into context, I have two other add-ons extending via XFCP_Thread. I have disabled them in an effort to troubleshoot--still no dice. I have tried to place my execution order for my class extension to lower than 10, but the issue still arises.

I have read the documentation a few [dozens of] times, watched official Xenforo guides, and scoured this forum.

Any insight would be much appreciated.

Thank you.
 
Last edited:
The class extension looks fine and should properly be resolved during normal usage (ie. when actionParent() gets called, your extended method will be hit). However, <xf:callback> does not pass classes through the class extension system and should typically be calling a static method on a relatively bare-bones class. Calling a controller action isn't really the envisioned use-case for it.
 
Thank you so much. I have been really scratching my head on this.

The method does have something to do with this. I get it now. I have been trying to return an object through the callback system using ($this->view($whatever)). For non-static methods, would I be php including the file into the template directly?

Thanks.
 
Callbacks are for static methods which return the desired output (as a string), nothing more. If you want to render a template from a callback, you can see here:

 
Top Bottom