How to use self-added dexterity fields in Plone5.1.1?

I added a new field to default dexterity content type "File".
How can I use this field in display, searching and collections? How to hide/show this field to some groups?
Does this in the same way for different field types?

Regards.
Hugo

To display the content of the field, you need to customize the template(s) for whatever view(s) you want it to appear in. There is some information about that here:
https://training.plone.org/5/mastering-plone/zpt_2.html

To use it in searching/collections, you need to add an index for the field:
https://docs.plone.org/external/plone.app.dexterity/docs/advanced/catalog-indexing-strategies.html
(Not sure if you are working on the filesystem on through-the-web, but there are instructions for both there.)

1 Like

Thanks,abosio :slight_smile:

  1. In order to make my self-added field searchable
    First I added this line in my profiles/default/types/File.xml
    <element value="collective.dexteritytextindexer.behavior.IDexterityTextIndexer" />

Then which file should I add these code to? :

from collective import dexteritytextindexer
from plone.autoform.interfaces import IFormFieldProvider
from plone.supermodel.model import Schema
from zope import schema
from zope.interface import alsoProvides
class IMyBehavior(Schema):
    dexteritytextindexer.searchable('specialfield')
    specialfield = schema.Text(title=u'Special field')
alsoProvides(IMyBehavior, IFormFieldProvider)
  1. I added a new dexterity content type, but I could not find the .xml file in the directory profiles/default/types/. Should I do it manually?

Regards.
Hugo