Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal (page) links on multilingual #10

Closed
miezo opened this issue Sep 25, 2019 · 2 comments
Closed

Internal (page) links on multilingual #10

miezo opened this issue Sep 25, 2019 · 2 comments

Comments

@miezo
Copy link

miezo commented Sep 25, 2019

I'm not sure how to handle this: I have a multilingual page. If I'm e.g. using a LinkIt field link on a page and the user selects a page from the dropdown when editing the french page (not the default language), it should then render a locale-aware link. So /mypage should be /fr/mypage.

For hardcoded page-links in the layout I used {{ get_content from="/mypage" }} {{ url }} {{ /get_content }} which gives me locale-aware links. I think the from parameter for get_content would also work with a page ID which is what LinkIt stores in the mypage.md.

Since I'm relatively new to Statamic I'm not sure if this should/could be handled in LinkIt or some other way (routes?) in Statamic.

Thanks for any hints.

@miezo
Copy link
Author

miezo commented Sep 27, 2019

I was able to solve it by prepending {{ locale_url }} to the page-link coming in from the LinkIt field:
<a href="{{ locale_url}}{{ myLinkitField | LinkIt:url}}">
this seems to work on all locales, including the default locale.

@miezo miezo closed this as completed Sep 27, 2019
@miezo miezo reopened this Sep 27, 2019
@miezo
Copy link
Author

miezo commented Sep 27, 2019

short addendum ('cause I'm an idiot): much better to use the {{ relate }} tag in this situation:

{{ relate myLinkIt_field.page }}
    {{ url }}
{{ /relate myLinkIt_field.page }}

will give the correct url according to the locale of the page that it's rendered.

@miezo miezo closed this as completed Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant