Skip to content

Instantly share code, notes, and snippets.

@SmetDenis
Last active August 13, 2016 17:35
Show Gist options
  • Save SmetDenis/9b51cf0554ad86eb23dea59407b53ad2 to your computer and use it in GitHub Desktop.
Save SmetDenis/9b51cf0554ad86eb23dea59407b53ad2 to your computer and use it in GitHub Desktop.
<?php
function externalItem(Item $item)
{
if ($this->app->jbenv->isSite()) {
return JRoute::_($this->app->route->item($item, false), false, 2);
} else {
$root = JUri::root();
$application = JApplicationCms::getInstance('site');
$router = $application->getRouter();
$link = $router->build($this->app->route->item($item, false));
return $root . preg_replace('/^.*administrator\//', '', $link, 1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment