2011-07-24 37 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