php - Joomla: How to get the URL of an associated menu item (Multilingual / from current page) -
i want manually add hreflang-attribute html-head of page.
i'm using joomla 3.4.8 + seblod component multilingual site. if associate menu items of different languages, "link-tag" , "hreflang-attribute" added head make relationship between menu items visible search engines.
for reason, tag not added, if i'm in list-and-search-view of seblod component. that's why manually want write missing tags head.
i know how add meta information head , how id of current menu item, but can't figure out how id (or seo-friendly url) of associated menu items of current page.
any ideas?
i hope described myself well... in advance!
example: menu item of current page in german language. associated / connected menu item in english language (which showing english version of current page). need sef-url of english menu item.
the easiest solution query active menu of variables menu. code below should return current active route menu:
$app = jfactory::getapplication(); $menu = $app->getmenu()->getactive(); $sefurl = $menu->route; echo '<pre>'; print_r($menu); echo '</pre>'; echo $sefurl; //here php set meta dynamically if need $doc =& jfactory::getdocument(); $doc->setmetadata( 'tag-name', 'tag-content', true );
if route being returned not correct route matches page can check see if link attribute includes index.php using strpos , concatenate , menu id run through jroute sef url so:
if(strpos($menu-link,'index.php?') !== false){ $sefurl = jroute::_($menu->link.'&itemid='.$menu->id); }
hope works you.
Comments
Post a Comment