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

Collection:next doesn't work with locales #1983

Closed
louis-schandeler opened this Issue May 30, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@louis-schandeler

louis-schandeler commented May 30, 2018

Describe the bug
I use the tag collection:next in my website but when i switch the language of my website, the collection:next displays the default locale content and not the translated language.

To Reproduce

{{ collection:next in="event" as="posts" limit="1" wrap="true" sort="event_date:desc" }}
{{ posts }}
{{ partial:card-next }}
{{ /posts }}
{{ /collection:next }}
@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 30, 2018

Fixed for next release.

You can patch this in statamic/bundles/Collection/CollectionTags.php at line 630.
Change to:

$this->collection = Entry::whereCollection($collection)->localize($this->get('locale', site_locale()))->values();
@louis-schandeler

This comment has been minimized.

louis-schandeler commented May 30, 2018

Thank you Jason.

But I find an other problem. I always have the first entry of the collection. Do you have a fast trick to resolve this ?

Thanks in advance

@louis-schandeler

This comment has been minimized.

louis-schandeler commented May 31, 2018

Hello Jason,

I edited this line too in the collection:next tag (statamic/bundles/Collection/CollectionTags.php at line 645) :

$current = Str::ensureLeft(URL::prependSiteRoot($this->get('current', URL::getCurrent()),site_locale()), '/');

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented May 31, 2018

Why?

@louis-schandeler

This comment has been minimized.

louis-schandeler commented May 31, 2018

Because the language prefix (/fr, /it, ...) was missing and the foreach defining the current index wasn't working.

@jasonvarga jasonvarga closed this May 31, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment