Joomla 2.5 - 从itemid获取sef url

时间:2012-08-20 09:51:25

标签: joomla sef

如何根据ID?

找到Menuitem的正确SEF网址
$link = JRoute::_( $menus->getItem( $id )->link.'&lang='.$languages[ $code ]->sef, true );

提供类似的内容:

http://localhost/<path>/component/content/?view=featured

但我想要的是从菜单中生成的网址,即:

http://localhost/<path>/<lang-sef-code>/<path>

我怎么能做到这一点?

1 个答案:

答案 0 :(得分:2)

我终于找到了解决问题的方法。

$languages = JLanguageHelper::getLanguages('lang_code');
foreach ($associations as $code => $id ) {
    item = $menus->getItem( $id );
    $link = JRoute::_( 'index.php?lang='.$languages[ $code ]->sef.'&Itemid='.$item->id );
}

这提供了:

http://localhost/<lang>/<path-to-link>

我注意到在处理SEF URL时,要比JRoute :: _()方法赋予vars的顺序是决定性的。我希望能帮助那些也遇到问题的人。

问候

philipp