Quantcast
Channel: Joomla! Forum - community, help and support
Viewing all articles
Browse latest Browse all 2396

General Questions/New to Joomla! 5.x • Re: url to news post?

$
0
0
You can get article's non-SEF link using Joomla\Component\Content\Site\Helper\RouteHelper::getArticleRoute(). Run in through Joomla\CMS\Router\Route::_() to get the SEF link:

Code:

use Joomla\CMS\Router\Route;use Joomla\Component\Content\Site\Helper\RouteHelper;$link = Route::_(RouteHelper::getArticleRoute($article->id . ':' . $article->alias, $article->catid, $article->language));
Yes, that's exactly what I was looking for, thanks! Using the code above does indeed take me to the correct article(s).

Now, if I want to just access the category of these news articles (the item in my Main Menu with the alias "nyheter"), can I use route to access that as well?

Statistics: Posted by SocketPup — Sun Apr 28, 2024 6:57 am



Viewing all articles
Browse latest Browse all 2396

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>