Inherit Subject script

Does anyone already have a 'inherit Subject script or action (or similar).

I have folders with content like this:

Iron Ships
1940-45
Company A
Images

If I tag (Subject) the folder 'Iron Ships' with 'Steel Ships', I want all containing items to have the keyword (also images inside Company A folder and the folders themselves'.

(and the same if 1940-45 folder is tagged with 'War')

I would set up some content rules for those folders
https://docs.plone.org/working-with-content/managing-content/contentrules.html

Your action could be a tales expression that executes a BrowserView that updates the subjects
here/@@update_subjects

Is there en existing 'view' / 'api call' that updates subjects ?

Not that I know of, I would get the subjects of the parent with obj.Subject(),
query the portal catalog with the path of the containing folder to to get the objects
https://docs.plone.org/develop/plone/searching_and_indexing/query.html#searching-for-content-within-a-folder
use obj.setSubject() to update the subjects list, and reindex the object obj.reindexObject(idxs=['Subject'])
https://docs.plone.org/develop/plone/searching_and_indexing/catalog.html

To get an idea: Search · Subject · GitHub

There is the @@fc-tags browser view which is called when editing tags in pat-structure (Classic folder_contents) ... the module is in plone.app.content.browser.contents.tag ... with the appropriate POST call and parameters this sets or removes tags from the content.

1 Like