简体   繁体   中英

Joomla Menuitem SEF url

I am building a module in Joomla. I am using the Module Parameter (Menuitem). It returns the menu id to the default.php file in the module.

I then build a URL with the following code:

$itemID = $params->get( 'url' ); // Menuitem id
$application = JFactory::getApplication();
$menu = $application->getMenu();
$item = $menu->getItem( $itemID );
$link = new JURI($item->link);
$link->setVar( 'ItemId', $itemid );
$articleLink = $link;

It works correctly but the link is not a SEF url:

It is:

index.php/component/content/article?id=25

instead of:

index.php/call-back-request

How would i convert the url to a SEF url? any help would be appeciated

You can create sef url using JRoute. This may help you-

$link=JRoute::_($link);

for more details read this- http://docs.joomla.org/Search_Engine_Friendly_URLs

Update:

//article sef
$catslug = $row->catid.':'.$row->category_alias;
$slug = $row->id.':'.$row->alias;
$link = JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM