How to create a router for a component in joomla?

How to create a router file for joomla component. I use Sef url in particular

+4
source share
3 answers

I had the same problem, and after the trawl over the Internet and only ever found answers like the one shown here ("see the documentation"), which is really useless, in my opinion, and all the documentation on Which this page is most useless.

In any case, I finally abandoned the "component router", I could make it easy to work on creating routes, but found that it would not parse anything and would not work at the same time, it was pointless.

In the end, I decided that going through the plugin was the answer and found this really good plugin here from Daniel Calviño Sánchez.

Then I finally came across the joomla documentation , which is perfect and will let you know exactly where you need to go.

I personally think that the joomla router needs a lot of work and saw that there are many ideas from people who want to update it. I found that using the plugin at the end was the easiest way and was the best solution in everything.

- , , , .

, .

+1

, , .

router.php Joomla\CMS\Router\SiteRouter

$this, , .

, var_dump($this)

.

$this->attachBuildRule(function(){
    // build rule code
});
$this->attachParseRule(function(){
   // parse rule code
});

, RouterInterface,

$this->attachBuildRule([$myRouter, 'build']);
$this->attachParseRule([$myRouter, 'parse']);

STAGE, . Router::PROCESS_* Joomla\CMS\Router

PHPStorm, :

/**
 * @var $this Joomla\CMS\Router\SiteRouter
*/
+1

.

, Routing Joomla.

com_content/router.php

0

Source: https://habr.com/ru/post/1622068/


All Articles