I use a boolean Field via Behavior for "News Item", if this checked then the News is a "Sticky News" and pinned on top of site in a viewlet.
I think it can be adapted for "isEmpty" or "shouldNotContain" or whatever.
You need a catalog index
<!--catalog.xml-->
<index
name="is_sticky"
meta_type="BooleanIndex">
<indexed_attr value="is_sticky" />
</index>
You need a indexer
<!--indexer.zcml-->
<configure xmlns="http://namespaces.zope.org/zope">
<adapter
factory=".my_indexer.sticky_news"
name="is_sticky" />
</configure>
# my_indexer.py
# -*- coding: utf-8 -*-
from plone.app.contenttypes.interfaces import INewsItem
from plone.indexer import indexer
from my.addon.behaviors.sticky_news import StickyNews
@indexer(INewsItem)
def sticky_news(obj):
"""Calculate and return the value for the indexer"""
sticky = StickyNews(obj)
if not sticky:
return False
return sticky.enable
You need a querystring definition
<!--registry.xml-->
<records
interface="plone.app.querystring.interfaces.IQueryField"
prefix="plone.app.querystring.field.is_sticky">
<value
key="title"
i18n:translate="">Sticky News</value>
<value key="description">check is the sticky news behavior available and set</value>
<value key="enabled">True</value>
<value key="sortable">False</value>
<value key="operations">
<element>plone.app.querystring.operation.boolean.isTrue</element>
<element>plone.app.querystring.operation.boolean.isFalse</element>
</value>
<value key="group">Custom</value>
</records>
with all these steps, a filter in a collection is available.