Unable to use the value variable inside array #8225
-
Statamic version: 4.1.1
The interiors variable is an image assets which has favorites field. I can get the index, but not value, the reason why I have to use the value, because the parent "favorites" variable will override the nested one. the usage is from offical doc, it seems it is outdated. any one know a workaround please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If the asset has its own I'm assuming where you are seeing the outer one, it's because that particular asset in the loop doesn't have its own You can get around this by using a scope. {{ favourites }}
{{ interiors scope="interior" }}
{{ interior:favourites }}
{{ /interiors }} By using the |
Beta Was this translation helpful? Give feedback.
If the asset has its own
favourites
variable, it should override the outer one.I'm assuming where you are seeing the outer one, it's because that particular asset in the loop doesn't have its own
favourites
.You can get around this by using a scope.
By using the
scope
, each iteration will be inside the given variable (interior
). So when you do{{ interior:favourites }}
, it will only get it from insideinterior
and won't fall back to the parent.