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 #__phocadownload_tags AS a' . ' WHERE a.id = ' . (int) $tagId;
$db->setQuery($query, 0, 1);
$tag = $db->loadObject();
/*if (!$db->query()) {
throw new Exception($db->getErrorMsg(), 500);
return false;
}*/
//Create the link
if (isset($tag->id)) {
$link = 'index.php?option=com_phocadownload&view=category&id=tag&tagid=' . (int) $tag->id;
} else {
$link = 'index.php?option=com_phocadownload&view=category&id=tag&tagid=0';
}
if ($item = self::_findItem($needles)) {
if (isset($item->query['layout'])) {
$link .= '&layout=' . $item->query['layout'];
}
if (isset($item->id)) {
$link .= '&Itemid=' . $item->id;
}
}
return $link;
}