Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Joomla 2.5--从itemid获取sef url_Joomla_Sef - Fatal编程技术网

Joomla 2.5--从itemid获取sef url

Joomla 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

如何根据菜单项的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
但我想要的是从菜单生成的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::\方法的顺序是决定性的。我也希望能帮助一些有问题的人

问候

菲利普