I'm trying to create a friendly URL for a custom component but i can't manage to find a solution. I have tried JRoute but it hasn't worked out for me (probably i'm not doing it right). Does anybody have any idea? I have created the router file and i read the documentation but i couldn't understand.
place?id=113?cat=3
i wanted it to be
place/113/3
UPDATE:
after implementing all methods i get the following error:
Argument 1 passed to ComponentRouter::__construct() must be an instance of CMSApplication or null
My code is:
class ContentRouter implements Joomla\CMS\Component\Router\RouterInterface
{
public function __construct(CMSApplication $app = null, AbstractMenu $menu = null)
{
$category = new RouterViewConfiguration('category');
$category->setKey('id')->setNestable();
$this->registerView($category);
$article = new RouterViewConfiguration('article');
$article->setKey('id')->setParent($category, 'catid');
$this->registerView($darticle);
parent::__construct($app, $menu);
$this->attachRule(new MenuRules($this));
$this->attachRule(new StandardRules($this));
$this->attachRule(new NomenuRules($this));
}
/* the other methods go here
}
I'm not sure if Joomla\CMS\Component\Router\RouterInterface
is the right class to be implement since there's no many examples but i followed along with the tutorial, i have implemented all the 3 methods and i yet get that error.
i
toI
, but if you make any more meaningful edits, please improve the grammar in the same edit.