Custom css using resource registries

I want to include some custom css and js files to templates of an addon package I am developing. I have added the files under the static folder. I wanted to register resources with the resource registries and hence I followed https://docs.plone.org/external/plone.app.dexterity/docs/advanced/static-resources.html#registering-a-static-resource-directory.
The custom css is not getting imported into the browserview, even after adding it to cssregistry.xml.
However, it is working if included as a style-slot in the template like below:

    <metal:block fill-slot="style_slot">
    <link rel="stylesheet" type="text/css"
        tal:define="navroot context/@@plone_portal_state/navigation_root_url"
        tal:attributes="href string:${navroot}/++resource++ploneorg.addonlisting/addonlist.css"
        />
     </metal:block>

what additional steps are needed after registering in the cssregistry.xml, to use the custom css classes in the templates?

You did not mention the Plone version you are using. cssregistry.xml is for Plone 4. Are you using Plone 5? Why your resource is missing will depend on:

(1) If Plone 4, whether you have run the import step in portal_setup for the CSS registry.

(2) If Plone 5, you will need to use registry.xml instead, which should include a snippet that looks something like this.

Sean

2 Likes

I just filed this https://github.com/plone/plone.app.dexterity/issues/250