How to find template for a page?

Is there an easy way to find the template for a page?
I am looking at a folder view and I dug inside the directories and found:

buildout-cashe/eggs/Products.CMFPlone-5.0.8-py2.7.egg/Products/CMFPlone/skins/plone_content/folder_listing.pt

but when I make changes to it and run buildout and restart clients it does not take effect.
How can I be sure if this template is responsible for a page? Is there a marker on the page or something?

Plone 5 has deprecated skins, so if you find a template in a skins/ folder, it's probably not the right one. For Plone 5, you can find the original template in plone/app/contenttypes/browser/templates/. Make a small change to the template and see if it shows up, that way you'll know it's the right one. You don't need to restart or anything, just refresh the page.

Now at this point, you will need to make a copy of that template in your own code that will override the version in eggs. z3c.jbot (https://pypi.org/project/z3c.jbot/) can help you create the override. Do you have any custom packages (policy or theme, etc) used in your buildout? The override would go in there.

You are referring to an obsolete template based on the old portal_skins tool (no idea why it is still around in Plone 5). The <body> tag of the HTML tells you which template name is used - something like

<body class="template-summary_view"...>

Since all views of Plone are now browser views there must be a related ZCML configuration in some configure.zcml file in one of the dozen Plone modules (or possible defined in the Python file of the related view).

Usually I would use something like this on the command line

grep -r summary_view plone.app.* | grep .zcml

or
grep -r summary_view plone.app.* | grep .py

Sometimes it may help to modify the main_template.pt in order to throw an error or a traceback...the traceback usually contains the full path of the related template.

-aj

See https://training.plone.org/5/mastering-plone/zpt_2.html#finding-the-right-template for documentation on how to find the template for a page you are looking at. The best solution is to use plone.app.debugtoolbar (option 2 in the docs).

1 Like

… if you are at someone else's computer or at an internet café in Cameroon :slight_smile:

go to yoursite.com/portal_view_customizations/registrations.html

Customize whatever template you think it is (do some changes to it)
See if it 'works'.
If not, try another

After you have found the right one, revert things by clicking the contents tab
Template file will tell you which template was used.

Don't do that, it will give you problems 'one day':
You should override it in you theme / or with jbot.

/portal_view_customization is not the perfect place to do customizations, but it is way better than editing files inside /buildout-cache

1 Like

Any package managed through zc.buildout - this includes all installed packaged are a taboo zone for modifications.

As said: z3c.jbot is the right tool for overriding an existing template from within your own package. So stay away from the pre-installed code...this approach is only suitable for checking or fast prototyping of changes but this is never ever a stable solution for production.

-aj

Thank you everyone for great suggestions. I found the template I wanted. The reason I wanted the template was to see why a Modification Date that is on a page (when you go to the page and is displayed at the top just below the Page name) is not consistent with the Modification Date that the shown under the page name in folder content view. Even though I can change the page modification date, it seems on the folder content view the modification date that is just underneath the page name does not change. Shouldn't those two be the same?

The reason I need to change the modification date is to keep meta data from another imported site.

Are you positive about customizing a template with a theme ? I tried that according to the doc for plone.app.themingplugins, created an override directory, came up with the squared root of nothing.
It seems that this is indeed how it is supposed to work, because only themes installed directly on disk can be customized, so a copy of a theme will not work; and a theme installed on disk can't be customized TTW. So it seems possible to customize a theme but not TTW, by running buildout. As a quick user friendly customization, that's not rating highly IMO, I think that the ZMI experience is far better. If you have found an easy way I'd be interested to know.

I think it can. In the theming control panel, customise it and give it the (excactly) same name as the original theme.

Also, I think (not sure) that if you add templates you need to restart or enable / disable the theme.

collective.jbot worked very well TTW, but I am not sure if it works with Plone 5.1

In the theming control panel, customise it and give it the (exactly) same name as the original theme.

I tried that and it gives me 2 themes with the same name, one (the original) that has no delete and modify buttons, the second (the copy) where it's possible. I'd think that if I called the second Great A'Tuin it would not make any difference.

Also, I think (not sure) that if you add templates you need to restart or enable / disable the theme.

Here is the relevant part of the code in the plugin.py file in the plone/app/themingplugins/overrides directory:

def onDiscovery(self, theme, settings, dependenciesSettings):
        res = queryResourceDirectory(THEME_RESOURCE_NAME, theme)
        if res is None:
            return

        directoryName = 'overrides'
        if 'directory' in settings:
            directoryName = settings['directory']

        if res.isDirectory(directoryName):

            layer = getattr(schemata, theme, None)

            if 'layer' in settings:
                layerName = settings['layer']

                try:
                    layer = resolve(layerName)
                except (ImportError, AttributeError,):
                    logger.warn("Could not import %s" % layerName)
                    return

            path = os.path.join(res.directory, directoryName)

            manager = z3c.jbot.metaconfigure.handler(path, layer)
            self.registered[theme] = manager

    def onCreated(self, theme, settings, dependenciesSettings):
        pass

    def onEnabled(self, theme, settings, dependenciesSettings):
        pass

    def onDisabled(self, theme, settings, dependenciesSettings):
        pass

don't seem to do much when the theme is disabled / enabled. It sure don't do anything for me to select another theme and to reselect the one with overrides. Maybe you used a special theme that implemented this feature by itself.

Then you have given it the wrong name. If you go to the theming control panel and 'Inspect' the theme, you can check the name in the manifest file.

Did you read https://github.com/plone/plone.app.themingplugins (and does changing the logo as stated there work ?) … it does for me...

well, I had tried first 'quintagroup.theme.sunrain', then I tried the title 'Sunrain Theme', with the same result, 2 copies one named quintagroup.theme.sunrain, the other Sunrain Theme.

title = Sunrain Theme
description = Sunrain Theme theme for Plone
preview = images/preview.png
rules = /++theme++quintagroup.theme.sunrain/rules.xml

I tried to override both, restart the server, well, nothing. Nothing at all.

To see if the problem was coming from a misunderstanding, I modified on the file system (in the buildout-cache theme directory) to do the same override, restarted the server, works.
I am not sure if you were meaning otherwise, but this is really completely conforming toe the EGG-INFO file (my reference) and your web reference, both are saying the same thing. I am not saying that this is false, I say that it's not impressive because it's just a regression in comparison to what was able to do Zope, well, aeons ago. And what is remaining of the Zope feature, the ZMI direct editing, is only half working and is planned to be removed...