I am using Joomla 4.2.1. I installed custom component which is previously used into Joomla 3.10.11.
I create a menu item with view from this component.
On Joomla 3.10.11 it works fine
for example : http://mylocal.local/index.php/kurse-nach-datum
But
on Joomla 4.2.1 it create url with view name
For example : http://mylocal.local/index.php/kurse-nach-datum/courses
kurse-nach-datum is the Alias of link
and link is index.php?option=com_course&view=courses
Router.php
<?php
/**
* @version 3.4.0
* @package com_course
* @copyright Copyright (C) 2015. All rights reserved.
* @license
* @author -
*/
// No direct access
defined('_JEXEC') or die;
/**
* @param array A named array
* @return array
*/
function CourseBuildRoute(&$query) {
$segments = array();
if (isset($query['task'])) {
$segments[] = implode('/', explode('.', $query['task']));
unset($query['task']);
}
if (isset($query['view'])) {
$segments[] = $query['view'];
unset($query['view']);
}
if (isset($query['id'])) {
$segments[] = $query['id'];
unset($query['id']);
}
return $segments;
}
/**
* @param array A named array
* @param array
*
* Formats:
*
* index.php?/course/task/id/Itemid
*
* index.php?/course/id/Itemid
*/
function CourseParseRoute($segments) {
$vars = array();
// view is always the first element of the array
$vars['view'] = array_shift($segments);
while(!empty($segments)) {
$segment = array_pop($segments);
if (is_numeric($segment)) {
$vars['id'] = $segment;
} else {
$vars['task'] = $vars['view'] . '.' . $segment;
}
}
return $vars;
}
implode('/', explode('.', $query['task']))
the same asstr_replace('.', '/', $query['task']))
?