Please help me find plone sunburst header HTML

Hello there,
I've been looking for hours and going through the plone documentation.

It's quite overwhelming, even for me who used to do some python scripting.
I was wondering if someone can help me find where the plone (latest version) header HTML is generated. Basically I wanted to rearrange elements in the site header, put some extra stuff and divs, but I have trouble finding the file that generates the HTML.

I found the theme page template, but all it has is this:

, but now i'm lost.. what exactly generates this, and how do I edit it?

I found the view_customizations, and it just says:

<div id="portal-header">
    <div tal:replace="structure provider:plone.portalheader" />
</div>

Would really appreciate it if someone can point me in the right direction.
Thank you!!!
PA

This is a great question, and it points to something we should think about in the documentation: often we document how to code something, but we don't explain how to reverse-engineer our code, which is quite complex. The latter is a skill that is very important for beginning Plone developers, who often have to figure out how to find the proverbial needle in the haystack.

Without any claims of exhaustiveness, here is my answer for how to find what you are looking for. Kudos for finding that snippet in view_customizations, it is the key!

The "structure provider:plone.portalheader" tells you that the HTML is inserted at that point by a viewlet manager called plone.portalheader. From experience I know where that viewlet manager is, but what if I didn't know? I would do a recursive grep for plone.portalheader in the omelette folder, or in the eggs folder. (If you don't have omelette, or don't know what it is, google collective.recipe.omelette, and add it to your buildout if you don't have it already.) The grep yields several results, but not overwhelmingly so. The most relevant ones are the viewlets.xml files and the configure.zcml files. In fact, there is only one configure.zcml file in the grep results, which tells me that the plone.portalheader viewlet manager is registered by the distribution called plone.app.layout.

Then you open the file plone/app/layout/viewlets/configure.zcml and find out that the viewlet manager plone.portalheader provides the interface IPortalHeader:

provides=".interfaces.IPortalHeader"

In the same file, search for IPortalHeader, and you'll discover all the viewlets that are registered for that viewlet manager. For example, the viewlet with the name plone.global_sections.

Some viewlets have the template defined right there in the zcml file. These, unfortunately, don't. So you look at the viewlet's class. The plone.global_sections viewlet has:

class=".common.GlobalSectionsViewlet"

Go and open the file common.py (in plone/app/layout/viewlets/), and look for the class GlobalSectionsViewlet. In it, you'll see:

index = ViewPageTemplateFile('sections.pt')

Boom! The sections.pt file is the template for this viewlet, which is rendered by the viewlet manager, which is replaced in the snippet you found.

Now you should be able to find all the other viewlets and their templates. That's useful, but your next problem will be how to customize them. In some cases, you'll be able to find the viewlets in portal_view_customizations, and customize them right there TTW (through the web). In other cases, you'll have to learn how to create your own viewlet and register it to the same viewlet manager, and hide the viewlet your own viewlet is replacing. There is extensive documentation on how to do that (which is not to say it's easy).

That's exactly what I was looking for. Thanks! I saw all the documentation on creating a viewlet.

I don't suppose I can edit the sections.pt right there and have it work? because every time I run buildout it will replace all my changes. Is there any way to direct buildout to keep this file? I am just wondering what is the simplest way to make a small change.

But for your usecase of wanting to fiddle with the header I would recommend
not finding where the HTML is generated and overriding it. Instead use
diazo and plone.app.theming to change just the bits that you want to
change. It is more explicit and less likely to break in an upgrade.