Backend\Modules\Pages\Engine\Model::getByTag PHP Method

getByTag() public static method

Get all items by a given tag id
public static getByTag ( integer $tagId ) : array
$tagId integer The id of the tag.
return array
    public static function getByTag($tagId)
    {
        // redefine
        $tagId = (int) $tagId;
        // get the items
        $items = (array) BackendModel::getContainer()->get('database')->getRecords('SELECT i.id AS url, i.title AS name, mt.module
             FROM modules_tags AS mt
             INNER JOIN tags AS t ON mt.tag_id = t.id
             INNER JOIN pages AS i ON mt.other_id = i.id
             WHERE mt.module = ? AND mt.tag_id = ? AND i.status = ?', array('pages', $tagId, 'active'));
        // loop items
        foreach ($items as &$row) {
            $row['url'] = BackendModel::createURLForAction('Edit', 'Pages', null, array('id' => $row['url']));
        }
        // return
        return $items;
    }