Piwik\Widget\WidgetContainerConfig::setLayout PHP Метод

setLayout() публичный Метод

By default widgets within a container are displayed one after another. In case you want to change this behaviour you can specify a layout that will be recognized by the UI. It is not yet possible to define custom layouts.
public setLayout ( string $layout ) : static
$layout string eg 'ByDimension' see {@link Piwik\Plugins\CoreHome\CoreHome::WIDGET_CONTAINER_LAYOUT_BY_DIMENSION}
Результат static
    public function setLayout($layout)
    {
        $this->layout = $layout;
        return $this;
    }

Usage Example

Пример #1
0
 private function buildGoalByDimensionView($idGoal, WidgetContainerConfig $container)
 {
     $container->setLayout('ByDimension');
     $ecommerce = $idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER;
     // for non-Goals reports, we show the goals table
     $customParams = array('documentationForGoalsPage' => '1');
     if ($idGoal === '') {
         // if no idGoal, use 0 for overview. Must be string! Otherwise Piwik_View_HtmlTable_Goals fails.
         $customParams['idGoal'] = '0';
     } else {
         $customParams['idGoal'] = $idGoal;
     }
     $translationHelper = new TranslationHelper();
     foreach ($this->allReports as $category => $reports) {
         $order = $this->getSortOrderOfCategory($category) * 100;
         if ($ecommerce) {
             $categoryText = $translationHelper->translateEcommerceMetricCategory($category);
         } else {
             $categoryText = $translationHelper->translateGoalMetricCategory($category);
         }
         foreach ($reports as $report) {
             $order++;
             if (empty($report['viewDataTable']) && empty($report['abandonedCarts'])) {
                 $report['viewDataTable'] = 'tableGoals';
             }
             if (!empty($report['parameters'])) {
                 $params = array_merge($customParams, $report['parameters']);
             } else {
                 $params = $customParams;
             }
             $widget = $this->createWidgetForReport($report['module'], $report['action']);
             if (!empty($report['name'])) {
                 $widget->setName($report['name']);
             }
             $widget->setParameters($params);
             $widget->setCategoryId($categoryText);
             $widget->setSubcategoryId($categoryText);
             $widget->setOrder($order);
             $widget->setIsNotWidgetizable();
             if (!empty($report['viewDataTable'])) {
                 $widget->forceViewDataTable($report['viewDataTable']);
             }
             $container->addWidgetConfig($widget);
         }
     }
 }