the frontend correctly ouputs the modified url. but I also expected the panel preview url to change accordingly, but it does not. even calling the url method explicitly does not help.
# site/blueprints/pages/subdomain.yml
title: Subdomain
options:
preview: "{{ page.url }}" # yields www.* but I expected subdomain.*
since the real implementation of my url component is way more complex I can not simply do a page method with the same code and use that as preview url. i need a reliable way to call the url component where the preview url is generated.
the panel is running on the www domain and all the preview links in the panel like for the content page of that subdomain are scoped to the www domain as well. like as if the url component is not running at all.
i have a check for css/js assets as well as tel/mailto links but those do not kick in for the panel preview url.
the code you linked confused me as it did seem to call itself on model→url() when no custom preview was set. i can not follow how that would resolve a models url to a human readable string.
the panel is running on the www domain and all the preview links in the panel like for the content page of that subdomain are scoped to the www domain as well. like as if the url component is not running at all.
i have a check for css/js assets as well as tel/mailto links but those do not kick in for the panel preview url.
the code you linked confused me as it did seem to call itself on model→url() when no custom preview was set. i can not follow how that would resolve a models url to a human readable string.
some closing context: the issue had come up when using the magnificient SEO Audit plugin by Johann Schopplich but it could not run the audit for pages that where mapped to another subdomain via the url component. with the preview: "{{ page.url([]) }}" that now works flawlessly.
But indeed it doesn’t look like it. @lukasbestle do you have a better understanding why the url core component doesn’t play a role in this, as it seems? Wouldn’t we have to wrap also the later returns in Page::url() with Url::to() as we do when $options isn’t null?
Looks like we didn’t think about the use case of rewriting model URLs to external domains via the url component.
However we cannot just call Url::to() from $page->url(), otherwise we will have a cyclic dependency as the default url component also calls $page->url() internally.
I’d say the more robust implementation would be to include the custom URL logic in a page model (overriding $page->url()) instead of in the url component.