public static function getRelated($id, $limit = 5)
{
$id = (int) $id;
$limit = (int) $limit;
// get the related IDs
$relatedIDs = (array) FrontendTagsModel::getRelatedItemsByTags($id, 'Blog', 'Blog', $limit);
// no items
if (empty($relatedIDs)) {
return array();
}
// get link
$link = FrontendNavigation::getURLForBlock('Blog', 'Detail');
// get items
$items = (array) FrontendModel::getContainer()->get('database')->getRecords('SELECT i.id, i.title, m.url
FROM blog_posts AS i
INNER JOIN meta AS m ON i.meta_id = m.id
WHERE i.status = ? AND i.language = ? AND i.hidden = ? AND i.publish_on <= ? AND i.id IN(' . implode(',', $relatedIDs) . ')
ORDER BY i.publish_on DESC, i.id DESC
LIMIT ?', array('active', LANGUAGE, 'N', FrontendModel::getUTCDate('Y-m-d H:i'), $limit), 'id');
// loop items
foreach ($items as &$row) {
$row['full_url'] = $link . '/' . $row['url'];
}
return $items;
}