Ticket #10280 (closed PLIP: wontfix)

Opened 6 years ago

Last modified 6 years ago

Allow overriding the <title> tag on a per-template basis.

Reported by: silviot Owned by: silviot
Priority: minor Milestone: 4.1
Component: Templates/CSS Version:
Keywords: Cc: gborelli, esteele

Description (last modified by gborelli) (diff)

Related to #8795

Motivation:

Currently (4.0a5) the title tag comes from a viewlet: plone.htmlhead.title, registered for the viewletmanager plone.htmlhead in plone.app.layout.viewlets.

If you want to write a .pt with a custom <title> tag you're out of luck: the discrimination for the viewlet registration is on the context and the request, the template used is not involved in the adapter lookup.

Proposal:

the <title> tag should be in a macro on his own. This would allow a template to override it. It should come from a view, not a viewlet. Reason: viewlets are good when you don't know in advance how many snippets you need in some place; views are good when you know you will need one snippet. (at least this is what I understood). Title tag belongs to the second category.

Can we make those changes to be backwards compatible? Probably not, since we need to pull out the old viewlet registration from the viewlet manager plone.htmlheader. Old customizations for the viewlet will insert a second <title> tag.

  • Pull out plone.htmlhead.title viewlet from plone.htmlhead ViewletManager.
  • Make it a view named plone.htmlhead.title.
  • Insert a new slot in main_template that more or less reads:
    <metal:titleslot define-slot="head_title_slot">
        <title tal:replace="structure context/@@plone_htmlhead_title">Plone</title>
    </metal:titleslot>
    

Risks: people relying on the old behaviour to customize the title will have to change their code, or the resulting html page will have two <title> tags.

Change History

comment:1 Changed 6 years ago by gborelli

  • Cc gborelli added
  • Description modified (diff)

comment:2 Changed 6 years ago by gborelli

  • Status changed from new to closed
  • Resolution set to fixed

(In [34378]) Changed way of specifying title tag in main_template. Now you can override the title tag in your template filling the 'head_title_slot' slot. Closes #10280

comment:3 Changed 6 years ago by gborelli

Theme authors should make changes in their main_templates.pt in according to these changes.

i.e.: they should include this code in their <head> tag

    <metal:titleslot define-slot="head_title_slot">
        <title tal:replace="structure context/@@plone_htmlhead_title">Plone Site</title>
    </metal:titleslot>

comment:4 Changed 6 years ago by kleist

"Theme authors should make changes in their main_templates.pt in according to these changes."

So we should make this a Documentation ticket?

comment:5 follow-ups: ↓ 6 ↓ 9 Changed 6 years ago by dukebody

  • Status changed from closed to reopened
  • Cc esteele added
  • Resolution fixed deleted

I have some questions:

  • Did you remove the plone.htmlhead.title registration from the plone.htmlhead viewlet manager in the related GenericSetup steps?
  • Why cannot you just define the macro in the viewlet?
  • Why don't you do the same for other parts of the page, like description, footer, colophon... In my opinion this change should be discussed as a PLIP for Plone 4.x.

comment:6 in reply to: ↑ 5 Changed 6 years ago by silviot

Replying to dukebody:

I have some questions:

  • Did you remove the plone.htmlhead.title registration from the plone.htmlhead viewlet manager in the related GenericSetup steps?

No, and I can't find it. Should it be in CMFPlone/profiles/default/viewlets.xml? Anyway, I think the viewletmanager should stay. It still hosts plone.htmlhead.dublincore.

  • Why cannot you just define the macro in the viewlet?

That would be awesome. Is it possible? I tried and couldn't do it. My understanding is that content injected in a template using "use-macro" is overridable with "fill-slot", but this is not the case, since the content any viewlet provides is ultimately included via a structure:provder.

  • Why don't you do the same for other parts of the page, like description, footer, colophon... In my opinion this change should be discussed as a PLIP for Plone 4.x.

Yes, you're right, it's a change that should be discussed first. I will revert back the new code (except for added tests) and file a PLIP. I also agree that the <title> tag is not be the only one that people want to override in their templates.

comment:7 Changed 6 years ago by silviot

I reverted the changes of r34378 in r34419, except one useful test in CMFPlone.

comment:8 Changed 6 years ago by esteele

When this was first proposed, the reception in #plone-framework was very positive. I'm in favor of including it, though as someone who doesn't do a lot of site customization, there may be holes that I don't see. Silviot, would you mind starting some discussion on the dev listserv?

comment:9 in reply to: ↑ 5 Changed 6 years ago by silviot

Replying to dukebody:

  • Why don't you do the same for other parts of the page, like description, footer, colophon... In my opinion this change should be discussed as a PLIP for Plone 4.x.

At first that seemed resonable to me but after a second thought the title tag seems the very important part to be able to customize, while the ability to customize e.g. the colophon (on a per-template basis) is less important.

Also I expect more people with a customized colophon viewlet than people with a customized title viewlet. Thus the impact of the change would be greater. (users/developers that didn't customize the title viewlet will only have to make a trivial change to their customized main_template)

comment:10 Changed 6 years ago by silviot

  • Type changed from Feature Request to PLIP
  • Milestone changed from 4.0 to 4.x

Seconding dukebody this is now a PLIP for 4.x

comment:11 Changed 6 years ago by silvio

  • Summary changed from It is impossible for a template using main_template to override the <title> tag. to Allow overriding the <title> tag on a per-template basis.

comment:12 Changed 6 years ago by esteele

  • Status changed from reopened to closed
  • Resolution set to wontfix
  • Milestone changed from 4.x to 4.1

This PLIP has been declined for consideration for Plone 4.1.

Framework Team voting on this PLIP was:

Alec -1 Craig -1 Elizabeth -1 Laurence -1 Martijn -1 Matthew -1 Rob -1 Ross -

The Framework Team felt that this was not a common enough need to implement it as a part of the Plone core.

Note: See TracTickets for help on using tickets.