I am building an addon that uses widgets. I have my admin page pulling all the widgets. Now I want to just get the custom widgets to display. Where in my code did I got wrong?
Maybe I am approaching it wrong. Any help would be much appreciated!
Code:
public function actionIndex($positions)
{
$widgetRepo = $this->getWidgetRepo();
$widgetsFinder = $widgetRepo->findWidgetsForList();
$widgets = $widgetsFinder->fetch();
foreach ($positions AS $position) {
$positionId = $position->position_id; // Example: Access the position ID
$positionName = $position->custom_widget_sidebar; // Example: Access the position name
$isActive = $position->active;
}
$groupedWidgets = $widgetRepo->groupWidgetsByPositions($widgets, $totalWidgets);
$positionsFinder = $widgetRepo->findWidgetPositionsForList();
$positions = $positionsFinder->fetch();
$positions[''] = null;
/** @var TYPE_NAME $positionId */
/** @var TYPE_NAME $positionName */
/** @var TYPE_NAME $isActive */
$viewParams = [
'positionId' => $positionId,
'positionName' => $positionName,
'isActive' => $isActive,
'groupedWidgets' => $groupedWidgets,
'positions' => $positions,
'totalWidgets' => $totalWidgets,
];
return $this->view('XF:Widget\Listing', 'custom_widget_list', $viewParams);
}
Maybe I am approaching it wrong. Any help would be much appreciated!