XF 2.2 How to get the forum list into a widget option page


Active member
Maybe there is someone who could tell me, on how I can get the forum list into the widget option page.
Do I need to fill the list of forum by myself?

There isn't a predefined widget for that - it would require custom development, or manually populating the widget template.
No I want to set the option of my widget, like extra field to lets say display the avatar in front of the user name. I also need to get the complete list of forums in there, so that the widget get only information of the selected one.


I found that code:

<xf:selectrow name="options[node_ids][]" value="{{ $options.node_ids ?: '' }}" multiple="multiple" size="7"
    label="{{ phrase('forum_limit') }}"
    explain="{{ phrase('only_include_threads_in_selected_forums') }}">

    <xf:option value="">{{ phrase('all_forums') }}</xf:option>
    <xf:foreach loop="$nodeTree.getFlattened(0)" value="$treeEntry">
        <xf:option value="{$treeEntry.record.node_id}" disabled="{{ $treeEntry.record.node_type_id != 'Forum' }}">
            {{ repeat('&nbsp;&nbsp;', $treeEntry.depth)|raw }} {$treeEntry.record.title}

But if I then open the widget option page, I get the following error:
  • Template admin:widget_def_options_tsk_mlam_widget: [E_USER_WARNING] Cannot call method getFlattened on a non-object (NULL) (src\XF\Template\Templater.php:1151)
This looks good, but I cannot download the addon from the referenced page. Account creation will be rejected all the time :(
This code need to be placed into the Class you extended the AbstractWidget

    protected function getNodeRepo()
        return $this->repository('XF:Node');
    protected function getDefaultTemplateParams($context)
        $params = parent::getDefaultTemplateParams($context);
        if ($context == 'options')
            $nodeRepo = $this->app->repository('XF:Node');
            $params['nodeTree'] = $nodeRepo->createNodeTree($nodeRepo->getFullNodeList());
        return $params;
Top Bottom