开发者

How to get an url to a menuitem from an article id in joomla 1.6?

开发者 https://www.devze.com 2023-03-22 09:41 出处:网络
I\'m writing a module that 开发者_JS百科has articles. I would like these article to end with the \"read more\" button. This button should redirect to a menuitem pointing to the full article if such a

I'm writing a module that 开发者_JS百科has articles. I would like these article to end with the "read more" button. This button should redirect to a menuitem pointing to the full article if such a menuitem exists, or to the article (as in component=com_content&id=... etc.) if this is not the case.

Right now I'm using JRoute with the id:

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

but this returns the following url:

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

This points to the correct article, but is not search-engine friendly (it is on, with .htaccess support) AND it leads to a different page than my menuitem pointing to the article.

I'm sure it has to do something with JRoute but I can't find any resource on how to make this work.

Any ideas? Thanks!


Try using the ComponentHelperRoute:

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

精彩评论

暂无评论...
验证码 换一张
取 消