Closed gcolson closed 2 years ago
Hi @gcolson,
A couple of things:
I think _slug
is the field you're looking for as opposed to name
, i.e.:
{% with_scope category: cat._slug %}
Also, you may simply get away with:
{% with_scope category: cat %}
I remember reading somewhere that when you're filtering based on a relation you can pass the whole object as opposed to the field and engine will get the _slug
automatically (but don't quote me on it).
If none of the above work, you may get some luck with:
{% with_scope category.in: [cat.name] %}
I seem to recall .in: []
being neccessary when you're targetting a collection/array (which one I forget).
Unfortunately the documentation on with_scope
is pretty sparse.
Hi !
Thanks for your answer. Too late for me so i just used the if
solution and that works fine.
I'm sure what you propose here should work, maybe i'll try it someday when i'm bored ;)
Hi,
I got stuck with a strange issue with the
with_scope
liquid tag. I'll try to explain it. I got two content types "positions" and "people", that have a many-to-many relation between them. "positions" has a select field called "category".Now i have this piece of code to try to display each people for each positions scoped by the category field. For each person i try to display all of its positions. Here is what it looks like :
The strange thing here is that using this code,
all_positions
is empty (even though my people are related to many positions). I just can't get the positions of a person. But if I don't usewith_scope
and replace it by anif
, that works :the
{% if position.category == cat.name %}
is the line that aimed to replacewith_scope
.I've struggled a long time to understand this, so I wanted to report it. Maybe it's my code that is not quite accurate, but for all the researchs I've made it seems like a bug to me.