2

When I use Route method to convert a normal url in a SEF url it doesn't work if the article is not a menu item. I don't understand if it's a normal behavior or if I'm doing something wrong. There is my example:

My $item->link is "index.php/eng/?view=article&id=29:article-name-1&catid=17".

  • If I use Route::_($item->link) I obtain an identical url.
  • If I use Route::_(RouteHelper::getArticleRoute($item->slug, $item->catid, $item->language), I obtain the same.

They always return "index.php/eng/?view=article&id=29:article-name-1&catid=17" ...but that's not a SEF url.

How can I obtain a SEF url even if the article is not connected to a menu item?

2 Answers 2

1

Route::_() expects a non-SEF URL as an input.

index.php/eng/?view=article&id=29:article-name-1&catid=17 is already an SEF URL, which is why Route::_() is not modifying it.

A non-SEF URL would be something like:

index.php?view=article&id=29:article-name-1&catid=17&lang=eng

2
  • I would prefer a conversion like this: index.php/eng/article/article-name-1 This already happen if an article is connected to a menu item, because the url is changed with something like "/menu-item/article-name-1"
    – Nintendomi
    Feb 18 at 10:27
  • @Nintendomi I don't think you can have a SEF such as the one you want without a direct link to the article. The Joomla Router requires that. As for what you get, it also depends on the other menu items on the site, such as maybe having a link to that particular category for instance.
    – Weeblr
    Feb 18 at 12:25
1

Apparently, this is now the expected behavior in J4. You need to create a menu item, but it doesn't have to be a menu item for a specific article. Creating a single "List All Categories" menu item is enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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