0

there is a helper coded:

JRoute::_(ContentHelperRoute::getCategoryRoute($item->id, $item->language))

It does precisely what I want it to do, but I need the same functionality for the "Featured" View...

Ideas?

1 Answer 1

1

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");
2
  • Thanks for that. This is all about trying to "re-purpose" the Category blog layout, but limit the display to "featured" articles... the options include showing or hiding featured, but not the option to filter to featured. Guess I'll have a look at the xml file to see if I can add that option.
    – ranwilli
    Commented Jun 7, 2017 at 14:00
  • Good Grief! The option to filter to only featured articles is indeed there! Gotta start reading things more carefully.
    – ranwilli
    Commented Jun 7, 2017 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.