All widgets within a subcategory will be rendered in the Piwik reporting UI under the same page. By default you do not have to specify any subcategory as they are created automatically. Only create a subcategory if you want to change the name for a specific subcategoryId or if you want to specifiy a different order so the subcategory appears eg at a different order in the reporting menu. It also affects the order of reports in API.getReportMetadata and wherever we display any reports. To define a subcategory just place a subclass within the Categories folder of your plugin. Subcategories can also be added through the {@hook Subcategory.addSubcategories} event.
 public function addSubcategories(&$subcategories)
 {
     $idSite = Common::getRequestVar('idSite', 0, 'int');
     if (!$idSite) {
         // fallback for eg API.getReportMetadata which uses idSites
         $idSite = Common::getRequestVar('idSites', 0, 'int');
         if (!$idSite) {
             return;
         }
     }
     $dimensions = $this->configuration->getCustomDimensionsForSite($idSite);
     $order = 70;
     foreach ($dimensions as $dimension) {
         if (!$dimension['active']) {
             continue;
         }
         $category = new Subcategory();
         $category->setName($dimension['name']);
         if ($dimension['scope'] === CustomDimensions::SCOPE_ACTION) {
             $category->setCategoryId('General_Actions');
         } elseif ($dimension['scope'] === CustomDimensions::SCOPE_VISIT) {
             $category->setCategoryId('General_Visitors');
         }
         $category->setId('customdimension' . $dimension['idcustomdimension']);
         $category->setOrder($order++);
         $subcategories[] = $category;
     }
 }
示例#2
0
文件: Dashboard.php 项目: piwik/piwik
 private function addDefaultSubcategory(&$subcategories)
 {
     $subcategory = new Subcategory();
     $subcategory->setName('Dashboard_Dashboard');
     $subcategory->setCategoryId('Dashboard_Dashboard');
     $subcategory->setId('1');
     $subcategory->setOrder(1);
     $subcategories[] = $subcategory;
 }
示例#3
0
文件: Goals.php 项目: piwik/piwik
 public function addSubcategories(&$subcategories)
 {
     $idSite = Common::getRequestVar('idSite', 0, 'int');
     if (!$idSite) {
         // fallback for eg API.getReportMetadata which uses idSites
         $idSite = Common::getRequestVar('idSites', 0, 'int');
         if (!$idSite) {
             return;
         }
     }
     $goals = API::getInstance()->getGoals($idSite);
     $order = 900;
     foreach ($goals as $goal) {
         $category = new Subcategory();
         $category->setName($goal['name']);
         $category->setCategoryId('Goals_Goals');
         $category->setId($goal['idgoal']);
         $category->setOrder($order++);
         $subcategories[] = $category;
     }
 }
示例#4
0
 public function buildPageMetadata(Category $category, Subcategory $subcategory, $widgetConfigs)
 {
     $ca = array('uniqueId' => $this->buildPageId($category->getId(), $subcategory->getId()), 'category' => $this->buildCategoryMetadata($category), 'subcategory' => $this->buildSubcategoryMetadata($subcategory), 'widgets' => array());
     foreach ($widgetConfigs as $config) {
         $ca['widgets'][] = $this->buildWidgetMetadata($config);
     }
     return $ca;
 }