Skip to main content
added 76 characters in body
Source Link
RichardB
  • 3.1k
  • 11
  • 14

getCategoryRoute basically justs returns a URL in the following format

index.php?option=com_content&view=category&id=[ID PARAMETER]&lang=[LANGUAGE PAREMETER]

It's not a particularly complicated function - the entirity is as follows:

if ($catid instanceof JCategoryNode)
        {
            $id = $catid->id;
        }
        else
        {
            $id = (int) $catid;
        }
        if ($id < 1)
        {
            $link = '';
        }
        else
        {
            $link = 'index.php?option=com_content&view=category&id=' . $id;
            if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
            {
                $link .= '&lang=' . $language;
            }
        }

This has nothing really to do with JRoute, to which you can pass any paramaterised URL you want to run through a router to get a clean URL. getCategoryRoute simply returns a parameterisd URL that works with com_content's category view.

It's not clear what you mean by "the same functionality", as com_content's featured view does not work in the same way as the category view. With thatthe featured view, categories are assigned as part of the menu item, and saved in the database as a menu item parameter, as opposed to being sent via URL parameters.

If you just want to create a link to the featured view using JRoute then the following should work (this will be all categories, though):

JRoute::_("index.php?option=com_content&view=featured&lang=[language]");

If the featured item is a menu item (with categories optionally assigned), then the following would also work:

JRoute::_("index.php?Itemid=MENUID");

getCategoryRoute basically justs returns a URL in the following format

index.php?option=com_content&view=category&id=[ID PARAMETER]&lang=[LANGUAGE PAREMETER]

It's not a particularly complicated function - the entirity is as follows:

if ($catid instanceof JCategoryNode)
        {
            $id = $catid->id;
        }
        else
        {
            $id = (int) $catid;
        }
        if ($id < 1)
        {
            $link = '';
        }
        else
        {
            $link = 'index.php?option=com_content&view=category&id=' . $id;
            if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
            {
                $link .= '&lang=' . $language;
            }
        }

This has nothing really to do with JRoute, to which you can pass any paramaterised URL you want to run through a router to get a clean URL. getCategoryRoute simply returns a parameterisd URL that works with com_content's category view.

It's not clear what you mean by "the same functionality", as com_content's featured view does not work in the same way as the category view. With that, categories are assigned as part of the menu item, and saved in the database as a menu item parameter, as opposed to being sent via URL parameters.

If you just want to create a link to the featured view using JRoute then the following should work:

JRoute::_("index.php?option=com_content&view=featured&lang=[language]");

If the featured item is a menu item, then the following would also work:

JRoute::_("index.php?Itemid=MENUID");

getCategoryRoute basically justs returns a URL in the following format

index.php?option=com_content&view=category&id=[ID PARAMETER]&lang=[LANGUAGE PAREMETER]

It's not a particularly complicated function - the entirity is as follows:

if ($catid instanceof JCategoryNode)
        {
            $id = $catid->id;
        }
        else
        {
            $id = (int) $catid;
        }
        if ($id < 1)
        {
            $link = '';
        }
        else
        {
            $link = 'index.php?option=com_content&view=category&id=' . $id;
            if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
            {
                $link .= '&lang=' . $language;
            }
        }

This has nothing really to do with JRoute, to which you can pass any paramaterised URL you want to run through a router to get a clean URL. getCategoryRoute simply returns a parameterisd URL that works with com_content's category view.

It's not clear what you mean by "the same functionality", as com_content's featured view does not work in the same way as the category view. With the featured view, categories are assigned as part of the menu item, and saved in the database as a menu item parameter, as opposed to being sent via URL parameters.

If you just want to create a link to the featured view using JRoute then the following should work (this will be all categories, though):

JRoute::_("index.php?option=com_content&view=featured&lang=[language]");

If the featured item is a menu item (with categories optionally assigned), then the following would also work:

JRoute::_("index.php?Itemid=MENUID");
Source Link
RichardB
  • 3.1k
  • 11
  • 14

getCategoryRoute basically justs returns a URL in the following format

index.php?option=com_content&view=category&id=[ID PARAMETER]&lang=[LANGUAGE PAREMETER]

It's not a particularly complicated function - the entirity is as follows:

if ($catid instanceof JCategoryNode)
        {
            $id = $catid->id;
        }
        else
        {
            $id = (int) $catid;
        }
        if ($id < 1)
        {
            $link = '';
        }
        else
        {
            $link = 'index.php?option=com_content&view=category&id=' . $id;
            if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
            {
                $link .= '&lang=' . $language;
            }
        }

This has nothing really to do with JRoute, to which you can pass any paramaterised URL you want to run through a router to get a clean URL. getCategoryRoute simply returns a parameterisd URL that works with com_content's category view.

It's not clear what you mean by "the same functionality", as com_content's featured view does not work in the same way as the category view. With that, categories are assigned as part of the menu item, and saved in the database as a menu item parameter, as opposed to being sent via URL parameters.

If you just want to create a link to the featured view using JRoute then the following should work:

JRoute::_("index.php?option=com_content&view=featured&lang=[language]");

If the featured item is a menu item, then the following would also work:

JRoute::_("index.php?Itemid=MENUID");