Collection

Table of contents

A collection of records for a certain Content Type. This object is returned when a content type for posts' plural name is called on site, e.g. site.pages. A collection is also returned when a content type’s plural name is called on the site.content_objects container object for generic content.

collection

When no attribute is called on the collection, it outputs all records inside as an array. E.g. calling site.pages just outputs all posts with the post_typepage.

collection.id_is_{:value}

Returns a single record by id. E.g. site.pages.id_is_1234 returns the post with post_typepage and id1234 and site.content_objects.categories.id_is_1234 does the same for the generic content type categories.

collection.{:content_field}_is_{:value}

Returns a single record by the value of a content_field. E.g.site.pages.custom_field_is_test_value returns the post with post_typepage and with the value of it’s content_fieldcustom_field astest_value.

collection['id_in_[{:value}, {:value}, …]']

Returns multiple records by array of id's. E.g. site.pages['id_in_[1234,9876]'] returns both the posts with post_typepage and id1234 and9876. Also, site.content_objects.categories['id_in_[1234,9876]'] does the same for the generic content type categories.

collection['{:content_field}_in_[{:value}, {:value}, …]']

Returns multiple records by the values of a content_field. E.g.site.pages['custom_field_in_[test_value1,test_value2]'] returns all posts with post_typepage and with the value of it’s content_fieldcustom_field astest_value1 ortest_value2. This also works the other way around: if a single value is passed all records containing that value will be returned. E.g.site.pages['custom_field_in_[test_value1]'] will return all posts where the value forcustom_field istest_value1

{:content_field}_in_{:collection}_as_{:value}

Returns multiple records by the values of a content_field. E.g.

test_value1.referenced_in_pages_as_custom_field returns all posts with post_type page and with the value of it’s content_field custom_field as test_value1.


Need help?

Do you have any question which is not answered in this knowledge base? Contact us. We are here to help you.