Is there any way to get from the article it's SEF URL?

   $id = JFactory::getApplication()->input->getInt('id');
   $article = JTable::getInstance("content");

searching something like this:

<?php echo $article->somethingLikeCanonicalSEFURL; ?>
  • @cilap I am rejecting this edit because changing one character is not a meaningful edit. Your suggested edit falls under the category of "no improvement whatsoever" (wording in the Review Queue). Yes, a should be an but that, of itself, is not a worthwhile edit. (not worth the +2 rep reward) What you could have done was: condensed any way, changed it's to its, removed all of the unnecessary <?php and ?> tags in the code blocks, reworded the English in the sentences. When you do wish to make an edit, please make it the "final edit" by fixing EVERYTHING possible. May 16, 2019 at 11:31
  • @Lodder please read above comment. May 16, 2019 at 22:35
  • @NeilRobertson please read above comment. May 16, 2019 at 22:36

1 Answer 1


To get SEF URL, pass non-SEF URL through JRoute::_(). To get non-SEF URL, you can use ContentHelperRoute::getArticleRoute().

// Load route helper class.
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');

// Build non-SEF URL.
$nonSefLink = ContentHelperRoute::getArticleRoute($article->id . ':' . $article->alias, $article->catid, $article->language);

// Build SEF URL.
$sefLink = JRoute::_($nonSefLink);

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.