2011-07-24 36 views
1

我在寫一個有文章的模塊。我希望這些文章以「閱讀更多」按鈕結束。如果存在這樣的菜單項或者文章(如在component = com_content & id = ...等),如果不是這種情況,該按鈕應該重定向到指向整篇文章的菜單項。如何從joomla 1.6中的文章ID獲取URL到菜單項?

現在我使用JROUTE與ID:

$url = JRoute::_('index.php?option=com_content&view=article&id='.$article->id); 

但這返回以下網址:

$url = "http://example.com/option=com_content&view=article&id=1" 

這指向正確的文章,但沒有搜索引擎友好(它支持.htaccess),它會導致與我的菜單項指向文章不同的頁面。

我敢肯定它做什麼JROUTE但我無法找到如何使這項工作的任何資源。

任何想法?謝謝!

回答

0

嘗試使用ComponentHelperRoute:

$link = JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catslug, $article->sectionid)); 
+0

感謝,有了它亂搞了一下,在getArticleRoute做一些更多的研究後,我發現這段代碼,最終使之成爲我的情況下工作:$ URL = JRoute :: _(ContentHelperRoute :: getArticleRoute($ article-> id,$ article-> catid)); – xaddict