Smart Folder / Collection NOT Criteria

Does anyone have code / add-on for NOT showing a (News) Item in a collection?

Basically, I want to keep some (old) news items, but not show them in /news

change their type?

1 Like

I was thinking more of a setting (or similar).

For example something like 'do not show in navigation'.
Then maybe the index could be 'not enabled' and this could be a criteria .

Alternatively, I could just modify the news template, but this might mess up batching (/?)

Gave me an idea: Maybe having another workflow (with a step of 'Archive') could be an idea

1 Like

Create an index „not_newsitem“ with a custom indexer.
The ZCatalog and collections do not support NOT by default.

For the sake of completion:

ZCatalog does support not queries (programmatically and only in certain fields):

https://github.com/zopefoundation/Products.ZCatalog/blob/master/CHANGES.rst#30a1-2012-04-22

Added support for not queries in field and keyword indexes. Both restrictions of normal queries and range queries are supported, as well as purely exclusive queries. For example: {‘foo’: {‘query’: [‘a’, ‘ab’], ‘not’: ‘a’}} {‘foo’: {‘query’: ‘a’, ‘range’: ‘min’, ‘not’: [‘a’, ‘e’, ‘f’]}} {‘foo’: {‘not’: [‘a’, ‘b’]}}. Note that negative filtering on an index still restricts items to those having a value in the index. So with 10 documents, 5 of them in the foo index with a value of 1, a query for not 1 will return no items instead of the 5 items without a value. You need to index a dummy/default value if you want to consider all items for a particular index.

and Plone 6 Listing block use it to remove the "itself" result from the result set using a not query with the UID of the current object.

but p.a.querystring (which powers the Collections) do not. It would be amazing if someone bake in the support on it, so the Collections and Plone 6 Listing block can benefit.

2 Likes

I think, I missed this :speak_no_evil:

I ended up doing something along the lines of what yurj: suggested, so I made another workflow step, which also included moving all news items to the 'archive folder'.