Back to PhocaGalleryRoute class

Method getCategoryRouteByTag

public static
getCategoryRouteByTag
(mixed $tagId)

Method getCategoryRouteByTag - Source code

public static function getCategoryRouteByTag($tagId)
{
    $needles = array(
        'category' => '',
        //'section'  => (int) $sectionid,
        'categories' => '',
    );
    $db = Factory::getDBO();
    $query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' . ' FROM #__phocagallery_tags AS a' . ' WHERE a.id = ' . (int) $tagId . ' ORDER BY a.id';
    $db->setQuery($query, 0, 1);
    $tag = $db->loadObject();
    //Create the link
    if (isset($tag->id)) {
        $link = 'index.php?option=com_phocagallery&view=category&id=tag&tagid=' . (int) $tag->id;
    } else {
        $link = 'index.php?option=com_phocagallery&view=category&id=tag&tagid=0';
    }
    if ($item = PhocaGalleryRoute::_findItem($needles)) {
        if (isset($item->query['layout'])) {
            $link .= '&layout=' . $item->query['layout'];
        }
        if (isset($item->id) && (int) $item->id > 0) {
            $link .= '&Itemid=' . $item->id;
        }
    }
    return $link;
}