getForMultipleItems() public static method

Get tags for multiple items.
public static getForMultipleItems ( string $module, array $otherIds ) : array
$module string The module wherefore you want to retrieve the tags.
$otherIds array The ids for the items.
return array
Example #1
0
 /**
  * Get all items between a start and end-date
  *
  * @param int $start  The start date as a UNIX-timestamp.
  * @param int $end    The end date as a UNIX-timestamp.
  * @param int $limit  The number of items to get.
  * @param int $offset The offset.
  * @return array
  */
 public static function getAllForDateRange($start, $end, $limit = 10, $offset = 0)
 {
     $start = (int) $start;
     $end = (int) $end;
     $limit = (int) $limit;
     $offset = (int) $offset;
     // get the items
     $items = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.id, i.revision_id, i.language, i.title, i.introduction, i.text, i.num_comments AS comments_count,
          c.title AS category_title, m2.url AS category_url, i.image,
          UNIX_TIMESTAMP(i.publish_on) AS publish_on, i.user_id, i.allow_comments,
          m.url
          FROM blog_posts AS i
          INNER JOIN blog_categories AS c ON i.category_id = c.id
          INNER JOIN meta AS m ON i.meta_id = m.id
          INNER JOIN meta AS m2 ON c.meta_id = m2.id
          WHERE i.status = ? AND i.language = ? AND i.hidden = ? AND i.publish_on BETWEEN ? AND ?
          ORDER BY i.publish_on DESC
          LIMIT ?, ?', array('active', FRONTEND_LANGUAGE, 'N', FrontendModel::getUTCDate('Y-m-d H:i', $start), FrontendModel::getUTCDate('Y-m-d H:i', $end), $offset, $limit), 'id');
     // no results?
     if (empty($items)) {
         return array();
     }
     // init var
     $link = FrontendNavigation::getURLForBlock('Blog', 'Detail');
     $folders = FrontendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Blog/Images', true);
     // loop
     foreach ($items as $key => $row) {
         // URLs
         $items[$key]['full_url'] = $link . '/' . $row['url'];
         // comments
         if ($row['comments_count'] > 0) {
             $items[$key]['comments'] = true;
         }
         if ($row['comments_count'] > 1) {
             $items[$key]['comments_multiple'] = true;
         }
         // allow comments as boolean
         $items[$key]['allow_comments'] = $row['allow_comments'] == 'Y';
         // reset allow comments
         if (!FrontendModel::get('fork.settings')->get('Blog', 'allow_comments')) {
             $items[$key]['allow_comments'] = false;
         }
         // image?
         if (isset($row['image'])) {
             foreach ($folders as $folder) {
                 $items[$key]['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $row['image'];
             }
         }
     }
     // get all tags
     $tags = FrontendTagsModel::getForMultipleItems('Blog', array_keys($items));
     // loop tags and add to correct item
     foreach ($tags as $postId => $data) {
         $items[$postId]['tags'] = $data;
     }
     // return
     return $items;
 }