Frontend\Modules\Faq\Engine\Model::getCategories PHP Method

getCategories() public static method

Get all categories
public static getCategories ( ) : array
return array
    public static function getCategories()
    {
        $items = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.*, m.url
             FROM faq_categories AS i
             INNER JOIN meta AS m ON i.meta_id = m.id
             WHERE i.language = ?
             ORDER BY i.sequence', array(LANGUAGE));
        // init var
        $link = FrontendNavigation::getURLForBlock('Faq', 'Category');
        // build the item url
        foreach ($items as &$item) {
            $item['full_url'] = $link . '/' . $item['url'];
        }
        return $items;
    }

Usage Example

Beispiel #1
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $categories = FrontendFaqModel::getCategories();
     $limit = $this->get('fork.settings')->get('Faq', 'overview_num_items_per_category', 10);
     foreach ($categories as $item) {
         $item['questions'] = FrontendFaqModel::getAllForCategory($item['id'], $limit);
         // no questions? next!
         if (empty($item['questions'])) {
             continue;
         }
         // add the category item including the questions
         $this->items[] = $item;
     }
 }
All Usage Examples Of Frontend\Modules\Faq\Engine\Model::getCategories