-
-
Notifications
You must be signed in to change notification settings - Fork 549
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
locales and locales:count does not work with Fluent Tags #11247
Comments
That tag relies on context in order to figure out what entry/page ID you're targeting. By default Blade doesn't get the context. The Antlers components do. You can tell it which ID you mean using the {{ Statamic::tag('locales:count')->id($id) }} I'd suggest just using the Antlers component syntax though. |
Ok that works. My suggestion/hope is that this would be added to the documentation for locale and locale:count, or maybe as a note for FluentTags somewhere. I did a search for any mention of this in locale, locale:count, blade documentation, and the Fluent Tag docs and didn't find any mention. I spent about 3 hours on trying to find a solution before just using @antlers tags, which worked just find in the blade template other then my IDE hates it haha. using the fluent tag is useful for things like assigning the count to the variable or doing other manipulations in blade. Also.. is there a way to make the @tags() markup work? maybe there should be a note for that documentation as well signifying that it won't work with all the tags. I found 3 other threads on the discord community where people were asking about this and seeking a fix, but nobody responded. I'm going to go respond to those threads now. Thanks for helping me find the solution! |
We can definitely make that clearer in the docs, thanks. I've made a note here to do that in here: statamic/docs#1573 |
Bug description
In my project, I had localizations for english and spanish. I attempted to use the locales:count to get the number of localizations on a given page. In blade, I could not get any of the methods working for getting the count or the locales other then using this method:
<s:locales:count />
I ran the example in the docs:
`{{-- Using Antlers Blade Components --}}
<s:locales:count />
<s:locales:count self="false" />
{{-- Using Fluent Tags --}}
{{ Statamic::tag('locales:count') }}
{{ Statamic::tag('locales:count')->self(false) }}`
returns
2
1
and then for the fluent tags
0
0
other methods such as @tags('locales'), does not seem to work either.
In the end I had to use @antlers @endantlers in order to get the functionality I needed.
How to reproduce
Setup a multisite page with a blade template. Test this:
I ran the example in the docs:
`{{-- Using Antlers Blade Components --}}
<s:locales:count />
<s:locales:count self="false" />
{{-- Using Fluent Tags --}}
{{ Statamic::tag('locales:count') }}
{{ Statamic::tag('locales:count')->self(false) }}`
notice that the FluentTags always just return 0. also if you do 'locales' it will always be an empty result when fetching.
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: