Back to PhocaGalleryRoute class

Method getCategoryRoute

public static
getCategoryRoute
(mixed $catid, mixed $catidAlias = '')

Method getCategoryRoute - Source code

public static function getCategoryRoute($catid, $catidAlias = '')
{
    // TEST SOLUTION
    $app = Factory::getApplication();
    $menu = $app->getMenu();
    $active = $menu->getActive();
    $option = $app->input->get('option', '', 'string');
    $activeId = 0;
    $notCheckId = 1;
    if (isset($active->id)) {
        $activeId = $active->id;
    }
    if ((int) $activeId > 0 && $option == 'com_phocagallery') {
        $needles = array('category' => (int) $catid, 'categories' => (int) $activeId);
        $notCheckId = 0;
        // when categories view, do not check id
        // we need to check the ID - there can be more menu links (to categories, to category)
    } else {
        $needles = array('category' => (int) $catid, 'categories' => '');
        $notCheckId = 0;
    }
    if ($catidAlias != '') {
        $catid = $catid . ':' . $catidAlias;
    }
    //Create the link
    $link = 'index.php?option=com_phocagallery&view=category&id=' . $catid;
    if ($item = PhocaGalleryRoute::_findItem($needles, $notCheckId)) {
        if (isset($item->query['layout'])) {
            $link .= '&layout=' . $item->query['layout'];
        }
        if (isset($item->id) && (int) $item->id > 0) {
            $link .= '&Itemid=' . $item->id;
        }
    }
    return $link;
}