use Joomla\CMS\Helper\RouteHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Factory; $articleId = 123; // replace with the actual ID of the article $articleUrl = Route::_(ContentHelperRoute::getArticleRoute($articleId)); echo "Link to article: My Article";
use Joomla\CMS\Helper\RouteHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Factory; $categoryId = 456; // replace with the actual ID of the category $categoryUrl = Route::_(ContentHelperRoute::getCategoryRoute($categoryId)); echo "Link to category: My Category";This example is similar to the previous one, but we are now using the `getCategoryRoute` method of `ContentHelperRoute` to generate the URL for a category. Again, we use the `Route::_` method to convert the Joomla route to a full URL. Both of these examples are part of the Joomla CMS codebase, specifically in the `com_content` component. The `ContentHelperRoute` class is located in the `administrator/components/com_content/helpers` directory.