Custom content type icon in folder_contents

I have several custom content types with its icons configured in fti. The icons are displayed correctly in the Add menu toolbar, but in the folder_contents all my custom content types display the file icon.

How must be specified the icon to be displayed correctly in the folder_contents?

You have to add icon records declaration in your profiles/defaults/registry.xml file.
The icons for default plone content types are declared here : plone.staticresources/src/plone/staticresources/profiles/default/registry/icons_contenttype.xml at master · plone/plone.staticresources · GitHub

If you have a new content type with the FTI name "MyNewContentType" and the bootstrap icon "MyBootstrapIcon.svg", your record will be:

    <record name="plone.icon.contenttype/MyNewContentType">
        <field type="plone.registry.field.TextLine">
            <title>MyNewContentType content type icon</title>
        </field>
        <value key="resource">++plone++bootstrap-icons/MyBootstrapIcon.svg</value>
    </record>

I knew the icon records and I already added the icon records for all my custom types, i.e. one of my custom types' icon record is:

  <record name="plone.icon.contenttype/ShippingAgent">
    <field type="plone.registry.field.TextLine">
      <title>Shipping Agent</title>
    </field>
    <value key="resource">++plone++bootstrap-icons/bicycle.svg</value>
  </record>

And it shows the bicycle icon in the Add menu but NOT in the folder_contents listing. In the folder_contents listing it show the file icon

If I don't recall wrong the toolbar icons come from field icon_expr in /types/MyType.xml.

For the folder_contents you need the registry and the problem here may be camel case? Checking my types I have types like "Mytype" and the registry looks like: <record name="plone.icon.contenttype/mytype"> so I would try to change the register to <record name="plone.icon.contenttype/shippingagent"> and see if this fixes it

1 Like

Are you sure it is the File icon? Can you inspect the html code and show the relative css? It would be useful to share Plone version too

Same result.

I'm on Plone 6.0.9
Here is the html code for the folder_contents icon

<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-file" viewBox="0 0 16 16">
  <path d="M4 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2zm0 1h8a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1"></path>
</svg>

Anyone knows where can I find the source code for the folder_contents template? I can only find references to it in some minified files in plone.staticresources.

Mmm is it working for me.

I would say inspect the folder_contents and see what class the <a> tag has contenttype-mytype

Check that exact registry exists: http://<Plone-path>/portal_registry/edit/plone.icon.contenttype/mytype

Refresh the CSS JS (CTRL + F5 or equivalent) in folder contents once the registry has been edited

1 Like

I have finally resolved it with the help of all you.
Thank you @sverbois @csanahuja @yurj for pointing me in the right direction.

FYI:

First of all, I must admit that in order to simplify the problem I omitted that my custom types are named with dots and some uppercase letters, like my.custom.PloneType.

After unminifying some js from plone.staticresources package (plone.app.layout was not useful) and debugging the resolveIcon function I found out that this function substitutes the dots by hyphen - and uppercase by lowercase. So the url for getting the icon is .../@@iconresolver/contenttype/my-custom-plonetype.

Therefore, I changed all the contenttype registry records according to this and the icon_expr in the fti also.

3 Likes