In admin side code:
use \Joomla\CMS\Router\Router;
$router = Router::getInstance('site');
$routedUrl = $router->build('index.php?option=com_content&view=article&id=1&Itemid=1');
$routedUrlAsString = $routedUrl->toString();
For menu item with alias 'foo' pointing at article 'bar':
https://my.site.tld/administrator/foo/bar
Method SiteRouter::build($url) prefixes the constructed SEF url with \JUri::base(true). When invoked from within admin code, JUri::base() returns an uri containing '/administrator', which is not the intention for a site SEF url.
Status | New | ⇒ | Discussion |
As far as I can see, the use of JUri::base() seems to be the main culprit. Other than that the constructed SEF url looks fine.
For my purpose, removing /administrator
is exactly what I do now
Labels |
Added:
J3 Issue
|
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-07-23 19:20:12 |
Closed_By | ⇒ | brianteeman |
This is probably addressed by #16879 and I'm not so sure there is anything sane to be done for 3.8 other than having a helper method that parses and removes the
/administrator
segment.