如何从joomla 1.6中的文章ID获取一个url到menuitem?

时间:2011-07-24 20:33:07

标签: joomla seo url-routing joomla-extensions joomla1.6

我正在写一篇有文章的模块。我希望这些文章以“阅读更多”按钮结束。如果存在这样的菜单项,则此按钮应重定向到指向完整文章的menuitem,或者如果不是这样,则重定向到文章(如component = com_content& id = ...等)。

现在我正在使用带有id的JRoute:

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

但是会返回以下网址:

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

这指向正确的文章,但不是搜索引擎友好的(它是开启的,带有.htaccess支持)并且它导致与我的menuitem指向该文章不同的页面。

我确信它必须与JRoute做点什么,但我找不到任何有关如何使这项工作的资源。

有什么想法吗?谢谢!

1 个答案:

答案 0 :(得分:0)

尝试使用ComponentHelperRoute:

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