Currently creating a url a site that is _not_ the current one is a bit verbose, e.g. in Twig:
siteUrl('my/path', null, null, 1)
It would be nicer if we could call it by handle, without passing all those unused params.
Something like this in UrlHelper, also exposed to Twig could work:
public static function siteUrlByHandle($siteHandle, string $path = '', $params = null, string $scheme = null)
{
$site = Craft::$app->getSites()->getSiteByHandle($siteHandle);
return siteUrl($path, $params, $scheme, $site->id);
}
Then one could do:
siteUrlByHandle('de', 'my/path')
鈥r this could be a method of craft\models\Site, in which case you could do:
craft.app.sites.getSiteByHandle('de').url('my/path')
Twig supports named arguments, so you can actually just do this:
{{ siteUrl('my/path', siteId=1) }}
Named args, how luxurious. What is this ES6?!
Had no idea, thanks.
Most helpful comment
Twig supports named arguments, so you can actually just do this: