XF 2.0 Widget setup step

AndrewSimm

Well-known member
I am trying to create widget "cis_ads_sidebar_1" from widget definition "cis_ads_side_bar_1". I can get everything to work when I manually set it up, but it doesn't create the widgets on my install step 1. Any idea? (I'm probably doing something in correctly with the multiple positions)

PHP:
    public function installStep1()
    {
        $this->createWidget('cis_ads_sidebar_1', 'cis_ads_side_bar_1', [
            'positions' => ['forum_list_sidebar' => 10],
            'positions' => ['forum_view_sidebar' => 10],
            'positions' => ['thread_view_sidebar' => 10]
        ]);

        $this->createWidget('cis_ads_sidebar_2', 'cis_ads_side_bar_2', [
            'positions' => ['forum_list_sidebar' => 20],
            'positions' => ['forum_view_sidebar' => 20],
            'positions' => ['thread_view_sidebar' => 20]
        ]);

        $this->createWidget('cis_ads_sidebar_3', 'cis_ads_side_bar_3', [
            'positions' => ['forum_list_sidebar' => 30],
            'positions' => ['forum_view_sidebar' => 30],
            'positions' => ['thread_view_sidebar' => 30]
        ]);

        $this->createWidget('cis_ads_sidebar_4', 'cis_ads_side_bar_4', [
            'positions' => ['forum_list_sidebar' => 40],
            'positions' => ['forum_view_sidebar' => 40],
            'positions' => ['thread_view_sidebar' => 40]
        ]);

        $this->createWidget('cis_ads_sidebar_5', 'cis_ads_side_bar_5', [
            'positions' => ['forum_list_sidebar' => 50],
            'positions' => ['forum_view_sidebar' => 50],
            'positions' => ['thread_view_sidebar' => 50]
        ]);
    }
 
You have multiple array keys named "positions", all of these will be overwriting each other.

You need to have one array with a key called positions, then put each position inside that, comma separated.
 
Is this correct?

PHP:
        $this->createWidget('cis_ads_sidebar_1', 'cis_ads_side_bar_1', [
            'positions' => ['forum_list_sidebar' => 10, 'forum_view_sidebar' => 10, 'thread_view_sidebar' => 10]
        ]);
 
Back
Top Bottom