Search code examples
phpjoomlasearch-enginesef

SEF url from module in joomla


I am making a module and trying to figure out how to get the Search engine friendly url to articles from this module

this is the helper class today

public function getItems($amount)
{
$db = &JFactory::getDBO();


$query = 'SELECT * FROM `#__content`, `#__content_frontpage` WHERE `#__content_frontpage`.content_id = `#__content`.id AND `#__content`.state = 1 ORDER BY `#__content`.publish_up DESC LIMIT ' . $amount  . '';



$db->setQuery($query);
$items = ($items = $db->loadObjectList())?$items:array();



return $items;
} //end getItems

And this is the default.php to display stuff

<ul class="frontpage_news">
    <?php foreach ($items as $item) { ?>
    <li>
    <div class="frontpage_date"><?php echo JText::sprintf('DATE_FRONTNEWS', $item->publish_up); ?></div>
    <div id="ffTitle" class="frontpage_title"><a href="#"><?php echo JText::sprintf('TITLE_FRONTNEWS', $item->title); ?></a></div>
    <div id="ffRead" class="frontpage_readmore"><a href="#"><?php echo JText::sprintf('READ_MORE_FRONTNEWS'); ?></a></div>
    </li>
    <?php } ?>
</ul>

So how do I get the correct link to each article displayed in SEF format?

Thanks for any help!


Solution

  • For Joomla 1.5:

    echo JRoute::_(ContentHelperRoute::getArticleRoute($article_id_and_alias, $category_id_and_alias, $section_id));
    

    For Joomla 1.6/1.7:

    echo JRoute::_(ContentHelperRoute::getArticleRoute($article_id_and_alias, $category_id));