Last active
January 17, 2020 19:17
-
-
Save b2z/eb11c3fc790784b51e87986790cfefc2 to your computer and use it in GitHub Desktop.
Get Joomla article SEF url by article alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db = JFactory::getDbo(); | |
$query = $db->getQuery(true); | |
$alias = 'title'; | |
$query->select($query->quoteName(array('id', 'catid'))) | |
->from($query->quoteName('#__content')) | |
->where($query->quoteName('alias') . ' = ' . $query->quote($alias)); | |
$item = $db->setQuery($query) | |
->loadObject(); | |
if (!empty($item)) | |
{ | |
JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php'); | |
$item->link = JRoute::_(ContentHelperRoute::getArticleRoute($item->id . ':' . $alias, $item->catid)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment