XF 2.0 Featured Thread Dev tutorial, unexpected protected

rivacom

Active member
I've been trying to follow the featured thread dev tutorial to build a featured thread addon. I get this error when I try to go to a Node's options.

Parse error: syntax error, unexpected 'protected' (T_PROTECTED) in /Demo/Portal/XF/Admin/Controller/Forum.php on line 12

Here is my code from that

PHP:
<?php

namespace Demo\Portal\XF\Admin\Controller;

use XF\Mvc\FormAction;

class Forum extends XFCP_Forum
{
    
}

protected function saveTypeData(FormAction $form, \XF\Entity\Node $node, \XF\Entity\AbstractNode $data)
{
    parent::saveTypeData($form, $node, $data);

    $form->setup(function() use ($data)
    {
        $data->demo_portal_auto_feature = $this->filter('demo_portal_auto_feature', 'bool');
    });
}

Any ideas what im missing?
 
b
I've been trying to follow the featured thread dev tutorial to build a featured thread addon. I get this error when I try to go to a Node's options.

Parse error: syntax error, unexpected 'protected' (T_PROTECTED) in /Demo/Portal/XF/Admin/Controller/Forum.php on line 12

Here is my code from that

PHP:
<?php

namespace Demo\Portal\XF\Admin\Controller;

use XF\Mvc\FormAction;

class Forum extends XFCP_Forum
{
   
}

protected function saveTypeData(FormAction $form, \XF\Entity\Node $node, \XF\Entity\AbstractNode $data)
{
    parent::saveTypeData($form, $node, $data);

    $form->setup(function() use ($data)
    {
        $data->demo_portal_auto_feature = $this->filter('demo_portal_auto_feature', 'bool');
    });
}

Any ideas what im missing?


Make sure brackets are in their proper position.
class Forum extends XFCP_Forum should not be closed and you have a missing bracket at the end.

Something like this should work

Code:
namespace Demo\Portal\XF\Admin\Controller;

use XF\Mvc\FormAction;

class Forum extends XFCP_Forum
{
    protected function saveTypeData(FormAction $form, \XF\Entity\Node $node, \XF\Entity\AbstractNode $data)
    {
        parent::saveTypeData($form, $node, $data);

        $form->setup(function() use ($data)
        {
            $data->demo_portal_auto_feature = $this->filter('demo_portal_auto_feature', 'bool');
        });
    }
}
 
Back
Top Bottom