I am receiving the error message "Impossible to invoke a method ("limit") on an array," but I don't think I am working with an array! Here is why I think that...
First I set an albums
variable:
{% set albums = craft.entries.section('townAlbums').with(['townPhotoAlbum']).relatedTo(entry) %}
Then I loop through that object. I'm not calling .all()
, so this is still an object, right?
{% for album in albums %}
Finally within this loop I am grabbing one image from the assets field townPhotoAlbum
to use as a thumbnail or cover image for this album:
{% set albumCover = album.townPhotoAlbum.limit(1) %}
Why is it complaining about using .limit()
on an array when it appears as though I'm still working with an object? Or am I overlooking something woefully obvious?
Thanks!