Cybo Advanced Field EngineCyboweb Technologies · Documentation · v1.0.2

Collection field

Purpose

A list of items with the same sub-fields: slides, team members, FAQs. Editors add, remove, reorder, duplicate and collapse items: the arrow at the end of an item (or its title) opens and closes it, and Collapse all / Expand all above the list (shown from two items) closes or opens every item at once.

Field type name

collection

Settings

Setting Description
Instructions Help text for editors, shown with the field.
Layout How the sub-fields are arranged for editors. Options: block (Block (fields below each other)), table (Table (fields side by side)), row (Row (labels on the left)).
Item Title Title of each item. Use sub-field names in braces, e.g. "Slide: {title}". Empty = "Item 1", "Item 2", …
Start Collapsed Show saved items collapsed, with only their title, to keep long lists tidy.
Button Label Text of the "Add Item" button.
Minimum Items Editors must add at least this many items. Empty = no minimum.
Maximum Items Editors cannot add more items. Empty = no limit.
Translation How the field behaves in other languages: translate, copy, copy_once or do_not_translate. Used on top-level fields when WPML is active. See WPML.
Width Width on edit screens, to place fields side by side: 100 (full), 75, 66, 50, 33 or 25 (%). Phones always show full width.
Label per language The label and instructions per language code while editing in that language, e.g. {"nl": {"label": "Prijs"}}. Set on the Translation tab when WPML is active. See WPML.

PHP return value

A list of items, each an array of sub-field values keyed by name; null when there are none. cafe_rows() returns row objects and [] instead of null.

Example

foreach ( cafe_rows( 'slides' ) as $slide ) {
	echo esc_html( $slide->get( 'title' ) );
}

// Save items from code:
cafe_update_field( 'slides', [
	[ 'title' => 'Welcome', 'image' => 12 ],
	[ 'title' => 'Sale' ],
] );