XF 2.1 get data from database to template

shqawe

Member
I am trying to add new field to Forum table and i already did it now i can add new icon to Forum table

but when i try to get this value in node_list_category template it doesn't show any thing

Listener file

PHP:
namespace CustomNodeIcon;

use XF\Mvc\Entity\Entity;

class Listener
{
    public static function forumEntityStructure(\XF\Mvc\Entity\Manager $em, \XF\Mvc\Entity\Structure &$structure)
    {
     
        $structure->columns['custom_icon'] = ['type' => Entity::STR];
       
        return $structure;
    }
}

Controller

PHP:
namespace CustomNodeIcon\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->custom_icon = $this->filter('custom_icon', 'str');
        });
    }
}

modification template

HTML:
<img src="{$forum.custom_icon}" width="30" height="30" />

also i try to change $forum to $node but also no result.
 
Last edited:
Back
Top Bottom