1

I'm relating entries from another site in my installation, and I'm having issues getting the correct URL for the entry. This is an example of what I currently have:

{% set carouselEntries = entry.contentCarouselEntries.all() %}

{% for entry in carouselEntries %}

    <a href="{{ entry.getUrl() }}">{{ entry.title }}</a>

{% endfor %}

This will get the correct title, however, it does not get the correct URL in that it does not include the site. Assume that the current site is mywebsite.com, and the URL for the site I'm retrieving the related entry is news.mywebsite.com. I'd expect the URL to be:

https://news.mywebsite.com/article/article-slug

Instead it's:

https://mywebsite.com/article/article-slug

The article/article-slug comes from Entry URI field in Settings > Sections > Site Settings > Entry URI Format

This is undoubtedly easy stuff, but I'm blanking on how to output this in my template?

I'm assuming that I need to query these entries in a different way? Whatever the solution, the entries need to output in the same order they were added to the entries field (contentCarouselEntries) on mywebsite.com.

Also, the solution needs to be dynamic in that I cannot just build the URL in my template like this:

https://news.mywebsite.com/article/{{ entry.slug }}

The related entries actually come from multiple sites in my installation including 'blog' and 'news', and from multiple environments like .local and .com. So, the link should include the site the entry is from and the environment you're in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.