如何根据菜单项的ID找到正确的SEF url?
$link = JRoute::_( $menus->getItem( $id )->link.'&lang='.$languages[ $code ]->sef, true );提供类似以下内容:
http://localhost/<path>/component/content/?view=featured但我想要的是从菜单中生成的url,即:
http://localhost/<path>/<lang-sef-code>/<path>我怎样才能做到这一点呢?
发布于 2012-08-20 18:50:37
我终于找到了解决我遇到的问题的办法。
$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时,将变量赋予JRoute::_()方法的顺序是决定性的。我希望能帮助那些在这方面也有问题的人。
问候
菲利普
https://stackoverflow.com/questions/12035528
复制相似问题