Strange extending issue...

Liam W

in memoriam 1998-2020
Since I tried to change to extending classes to just extending templates, and then changing it back again, the extension on XenForo_ViewPublic_Thread_View doesn't work at all - I know, because I'm outputting debug text to the screen at the beginning of the extension, and it doesn't print out.

The other 2 view classes I'm extending extend fine, it's just the thread view that doesn't.

I've no idea how to go about troubleshooting this. Any ideas?

Liam
 
You're going to have to post some code and your code event listeners.

Well:

Event listener function:

PHP:
/**
    * Listener to extend classes for drop down.
    * @param string $class
    * @param array $extend
    */
    public static function extendClass($class, array &$extend)
    {
        switch ($class)
        {
            case "XenForo_ViewPublic_Thread_Create":
            case "XenForo_ViewPublic_Thread_Reply":
            case "XenForo_ViewPublic_Thread_View":
                $extend[] = 'LiamMacros_ViewPublic_Thread_View';
                break;
        }
       
        return true;
    }

Extender:

PHP:
<?php

class LiamMacros_ViewPublic_Thread_View extends XFCP_LiamMacros_ViewPublic_Thread_View
{
    public function renderHtml()
    {
        /* Get current userId */
        $userid = XenForo_Visitor::getUserId();
       
        /* @var $model LiamMacros_Model_Macros */
        $model = XenForo_Model::create('LiamMacros_Model_Macros');
       
        /* @var $usermode XenForo_Model_User */
        $usermodel = XenForo_Model::create('XenForo_Model_User');
       
        /* Get user macros */
        $usermacros = $model->getMacrosForUser($userid, true, true);
       
        /* and admin ones... */
        $adminmacros = $model->getAdminMacrosForUser($usermodel->getFullUserById($userid), true);
       
        $visitor = XenForo_Visitor::getInstance();
       
        if (is_array($usermodel->getFullUserById($userid)))
        {
            $this->_params['macros'] = $model->prepareArrayForDropDown($usermacros, $adminmacros);
           
            $this->_params['canviewmacros'] = $model->canViewMacros($visitor);
            //XenForo_CodeEvent::fire('liammacros_insert_dropdown', array(&$this->_params['macros'], &$this->_params['canviewmacros']));
        }
        parent::renderHtml();
    }
   
}

//class XFCP_LiamMacros_ViewPublic_Thread_View extends XenForo_ViewPublic_Thread_View {}

The first two classes of the extension extend fine, the final one doesn't...
 
XenForo_Application::resolveDynamicClass('XenForo_ViewPublic_Thread_View')

Returns XenForo_ViewPublic_Thread_View...
 
ok erase that and add
Code:
$this->_params['test'] = true;
at the top of your renderHtml() function.

and add
Code:
{xen:helper dump, {$test}}
to your template.
 
Ok, odd..
Try adding
Code:
echo 'test';
to the top of that function instead.
Do you have any other add ons installed that effect that template/renderer?
 
Ok, odd..
Try adding
Code:
echo 'test';
to the top of that function instead.
Do you have any other add ons installed that effect that template/renderer?

SNAP!

After disabling my hide user signatures addon it all worked :P

Looks like I forgot to call the parent in that addon.... (whoops!)

Thanks :P
 
lol. Glad I could help.

On a side note, may I ask why you have
PHP:
if (is_array($usermodel->getFullUserById($userid)))
I feel like you're adding an extra query when you don't need to.
 
lol. Glad I could help.

On a side note, may I ask why you have
PHP:
if (is_array($usermodel->getFullUserById($userid)))
I feel like you're adding an extra query when you don't need to.

I think it was to check for a guest or something else, otherwise it would error out. However I could use the vistior instance I have setup instead I guess...
 
I think it was to check for a guest or something else, otherwise it would error out. However I could use the vistior instance I have setup instead I guess...
Just figured I'd point out that you most likely don't need that extra query. Yeah, I'd recommend using the visitor instance.
 
Top Bottom