Exclude Items by Default¶
The Exclude Items by Default feature allows folderish content types to omit child items from the REST API response. This avoids unnecessary catalog queries for blocks-based content where child items are already provided via Simplelayout blocks (slblocks).
Overview¶
By default, the REST API response for any folderish content includes up to 25 child items. For blocks-based pages this is wasted computation — the frontend uses slblocks for rendering, not items.
When the IExcludeItemsByDefault behavior is active on a content type, the REST API serializer returns:
items: empty list ([])items_total:0slblocks: populated as usual
The exclusion can be overridden per-request with the query parameter force_include_items=1.
REST API¶
Default Response (items excluded)¶
const response = await fetch('/Plone/my-page', {
headers: { 'Accept': 'application/json' }
});
const data = await response.json();
console.log(data.items); // []
console.log(data.items_total); // 0
console.log(data.slblocks); // [...] blocks still present
Force Including Items¶
Pass force_include_items=1 to bypass the exclusion and retrieve child items normally:
const response = await fetch('/Plone/my-page?force_include_items=1', {
headers: { 'Accept': 'application/json' }
});
const data = await response.json();
console.log(data.items); // [{...}, {...}, ...]
console.log(data.items_total); // 5
import requests
response = requests.get(
'http://localhost:8080/Plone/my-page',
params={'force_include_items': '1'},
headers={'Accept': 'application/json'}
)
data = response.json()
print(data['items'])
Configuration¶
The behavior is opt-in. To activate it on a content type, add
wcs.backend.content.behaviors.exclude_items.IExcludeItemsByDefault to the
FTI’s behaviors list via GenericSetup:
<object name="MyContentType" meta_type="Dexterity FTI">
<property name="behaviors" purge="false">
<element value="wcs.backend.content.behaviors.exclude_items.IExcludeItemsByDefault"/>
</property>
</object>