Search code examples
plonedexterity

How can I customize how the title is displayed?


I want to customize how the HTML for the title of my Dexterity content type is generated.

I wrote a view template for a the type that uses the metadata.IBasic behavior:

<html ...>
  <body>
    <metal:content-core fill-slot="content-core">
      <metal:content-core define-macro="content-core">
        <div id="conent-images">...</div>
        ...
        <div id="content-metadata">
          <h1 tal:content="context/title">Title</h1>
          ...
        </div>
        ...
        <div id="content-body">...</div>
      </metal:content-core>
    </metal:content-core>
  </body>
</html>

But Plone then renders the title twice. How can I remove the first apparition of title?


Solution

  • With that code you are filling the slot named content-core. There are several slots defined in the layout that is the base for the template: content-title, content-description y content-core.

    To remove the first title apparition you can fill the the content-title slot with nothing.

    <html ...>
      <body>
        <metal:content-core fill-slot="content-title">
          <metal:content-core define-macro="content-title">
          </metal:conent-core>
        </metal:conent-core>
        <metal:content-core fill-slot="content-core">
          <metal:content-core define-macro="content-core">
            ...
            <h1 tal:content="context/title">Title</h1>
            ...
            <div id="content-body">...</div>
          </metal:content-core>
        </metal:content-core>
      </body>
    </html>
    

    Other solution is edit the template where slots are defined, but this solution is enough for me.