Section settings
Settings for sections, in alphabetical order:
$co->createSection(
->layout('cards')
If no default value is mentioned, the setting will default to empty
(empty string, empty array, null, depending on the type).
actions
- Type:
array
The actions available to the section. See Actions.
->actions([
'slideout', // Predefined actions
'delete',
'view',
$co->createAction(...),
$co->createAction(...),
])
allSites
- Type:
bool
- Default:
false
true = display unique entries from all sites.
->allSites(true)
entryType
- Type:
array|string
Narrow query results by entryType handle
->entryType('privacy')
fallbackImageField
- Type:
array|string
Name of an image field to use if there is no image set in imageField
.
->fallbackImageField('photo')
filters
- Type:
array
Array of filter definitions. See Filters.
->filters([
$co->createFilter('field', 'topics'),
$co->createFilter('field', 'workflowStatus'),
])
filtersPosition
- Type:
string
- Default:
inline
Positions of filter inputs.
inline
beneath search inputstop
above search inputsbottom
below search inputs
->filtersPosition('bottom')
heading
- Type:
string
Heading of the section. The Section::getHeading()
method will return Crafts section names, if this setting is empty.
->heading('Upcoming Events')
help
- Type:
array|string
Help text for the section. See Help for more options.
->help('Help is on the way!')
icon
- Type:
array|string
Path to a svg icon that will be displayed if no image is found. Can contain aliases.
See Multi Section Setup.
->icon('@appicons/wand.svg')
iconBgColor
- Type:
string
- Default:
var(--gray-200)
The background color for an icon.
->iconBgColor('#e4e4e4')
imageField
- Type:
array|string
Name of the image field to use.
See Multi Section Setup.
->imageField('featuredImage')
imageRatio
- Type:
float
Aspect ratio of the image. Only makes sense for card layout.
If empty, the transforms setting wil determine the aspect ratio.
->imageRatio(5/4)
info
- Type:
string|array
Object template to render in addition to the title.
See Multi Section Setup.
->info('{postDate|date("short")}')
infoTemplate
- Type:
string|array
Path to a twig template inside the custom template root. Will be called with entry
and sectionConfig
variable.
See Multi Section Setup.
->infoTemplate('infos/workflowstatus.twig')
layout
- Type:
string
The layout used to display entries. (list|cardlets|cards|line|table)
The Section::getLayout()
method will take the defaultLayout plugin setting into account, if this setting is empty.
->layout('cards')
limit
- Type:
int
- Default:
9999
Number of entries to show on one section page.
->limit(12)
linkToPage
- Type:
string
The key of a page the heading is linked to. May contain an anchor, e.g. page1#tab1
.
->linkToPage('page1')
orderBy
- Type:
string|array
The sort order used by the sections query. If empty, the Crafts defaults will be used.
See docs
->orderBy('postDate desc')
ownDraftsOnly
- Type:
bool
- Default:
false
If true and scope is defined: show only drafts created by the current user.
->ownDraftsOnly(true)
query
- Type:
ElementQuery
Define your own query.
use craft\elements\Entry;
->query(Entry::find()->customField('value'))
scope
- Type:
string
Whether drafts should be shown.
- drafts: Show 'regular' drafts
- provisional: Show 'provisional' drafts
- ownProvisional: Show own 'provisional' drafts
- all: Show all drafts and all 'published' entries
If empty, only 'published' entries will be included.
->scope('drafts')
search
- Type:
bool
- Default:
false
Whether search will be enabled.
->search(true)
searchAttributes
- Type:
array
Prefixes for search. See Searching.
->searchAttributes([
['label' => 'Title', 'value' => 'title'],
['label' => 'Body Content', 'value' => 'bodyContent'],
])
section
- Type:
array|string
Craft section handle(s).
Will be passed to the section query, however if a query
setting is set, it will only be used for default headings/permission checks.
->section('news')
showIndexButton
- Type:
bool
- Default:
true
Whether button 'All entries' will be shown.
->showIndexButton(false)
showNewButton
- Type:
bool
- Default:
true
Whether button 'New entry' will be shown.
->showNewButton(false)
showRefreshButton
- Type:
bool
- Default:
true
Whether to show a refresh button for this section.
->showRefreshButton(false)
size
string, the grid colum size of an entry for layouts card, cardlet. (tiny|small|medum|large|card)
->size('small')
sortByScore
- Type:
bool
- Default:
false
Whether search results will be sorted by score.
->sortByScore(true)
status
- Type:
string|array
See docs
If empty, all entries with all status (live, disabled, pending, expired) will be found.
->status('pending')
titleObjectTemplate
- Type:
string
- Default:
{title}
An object template that will be rendered for the title in a layout.
->titleObjectTemplate('{lastName}, {firstName}')