2011-09-22 99 views
1

我想提出一個模塊,並試圖找出如何從這個模塊SEF URL中的Joomla

這是輔助類獲得搜索引擎友好的URL文章今天

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 

而且這是如default.php顯示的東西

<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> 

那麼,如何得到正確的鏈接到SEF格式顯示的每一篇文章?

感謝您的幫助!

回答

4

爲Joomla 1.5:

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

爲Joomla 1.6/1.7:

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

謝謝!在這裏找到一篇關於它的偉大文章!至http://www.joomladin.com/index.php/tutorials/34-module-development/57-link-to-an-article.html – Tobias