-- HikaShop version -- : 4.7.1
-- Joomla version -- : 4.2.7
-- PHP version -- : 7.4
Hello,
I'm currently creating a better finder plugin for hikashop and I'm running into serious issues with the router. The URLs are simply completely wrong, which is mainly due to the Itemid being hardcoded to the URL. When I look at the router, I also see issues there and it would start with unnecessarily complex code there. The question would be, which Joomla versions you are supporting, because unless you are support Joomla from before 3.6, you could drop half the code in your router.
To be specific:
<?php
$jversion = preg_replace('#[^0-9\.]#i','',JVERSION);
if(version_compare($jversion,'4.0.0','>=')) {
class hikashopRouter extends Joomla\CMS\Component\Router\RouterBase {
public function build(&$query) {
return _HikashopBuildRoute($query);
}
public function parse(&$segments) {
return _HikashopParseRoute($segments);
}
}
}
function HikashopBuildRoute( &$query ) { return _HikashopBuildRoute($query, ':'); }
function _HikashopBuildRoute( &$query, $separator = '-' )
{
...
}
function HikashopParseRoute( $segments ) { return _HikashopParseRoute($segments, ':'); }
function _HikashopParseRoute( &$segments, $separator = '-' )
{
....
}
function hikashop_retrieve_url_id(&$vars,$name){
...
}
could be replaced with
<?php
class hikashopRouter extends JComponentRouterBase {
public function build(&$query) {
...
}
public function parse(&$segments) {
...
}
protected function hikashop_retrieve_url_id(&$vars,$name){
...
}
}
Where ... is the actual program code. That code would be working from Joomla 3.6 onwards.
Besides that, it would be nice if the router would discover the Itemid dynamically similar to how the core does it. That means that you don't have to store the Itemid in the finder and if you change your sites structure, move a category to a different place or something similar, your URLs would still be correct.
If you are interested in a rewrite of either the router or the finder plugin, feel free to contact me.