Joomla 2.5--从itemid获取sef url
如何根据菜单项的ID找到正确的SEF urlJoomla 2.5--从itemid获取sef url,joomla,sef,Joomla,Sef,如何根据菜单项的ID找到正确的SEF url $link = JRoute::_( $menus->getItem( $id )->link.'&lang='.$languages[ $code ]->sef, true ); 提供如下内容: http://localhost/<path>/component/content/?view=featured http://localhost//component/content/?view=featured
$link = JRoute::_( $menus->getItem( $id )->link.'&lang='.$languages[ $code ]->sef, true );
提供如下内容:
http://localhost/<path>/component/content/?view=featured
http://localhost//component/content/?view=featured
但我想要的是从菜单生成的url,它是:
http://localhost/<path>/<lang-sef-code>/<path>
http://localhost///
我怎样才能做到这一点呢?我终于找到了解决问题的办法
$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>
http://localhost//
我注意到,在处理SEF URL时,变量被赋予JRoute::\方法的顺序是决定性的。我也希望能帮助一些有问题的人
问候
菲利普