Kung Fu Kung Fu

Fujian White Crane Kung Fu

Zope Zope

What I have and am doing with Zope

Photos Photos

Photoalbum, both old and new.

Receptsamlingen Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me Contact me

My contact details and how to contact me.

  Mobile version of this page Mobile version of this page


 

TAL here hack in Plone

hack, metal, document_view, document_view.pt, index_html_content, index_html

28th of April 2005

Had to do a very useful and ugly but also smart hack in Plone today.

In the portal root I have a Document with Id index_html that the client is changing with the WYSIWYG editor. What I wanted to do was to change some METAL calls in the <head> tag of that one document. In fact, what I wanted to do was to cover up the left hand column which is done this way:

   <head>
        <metal:override fill-slot="column_one_slot" />
  </head>

The problem was that the index_html Document is a Document so I can't edit it's TAL. I could have customized document_view.pt but that would have applied for all Document objects in the site. Here's how I solved it:

I renamed index_html to index_html_content and created a Page Template object in the portal root. The code for this one I got from portal_skins/plone_content/document_view.pt. Then I added the metal:override as shown above.

But I wanted this new index_html to render the content of the index_html_content object so that in, index_html I can (continue to) do stuff like here/getBody and here/Title. So what did I do? Here's a cut down copy of the index_html code:

 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      
lang="en"
      
metal:use-macro="here/main_template/macros/master"
      
i18n:domain="plone">
  <head>
        <metal:override fill-slot="column_one_slot" />
  </head>
  <body>
  <metal:main fill-slot="main">
    <!-- here's my hack! --> 
    <tal:hack define="here nocall:here/index_html_content">
      <tal:main-macro metal:define-macro="main"
           
tal:define="len_text python:len(here.text);">
        <h1 tal:content="here/title_or_id" class="documentFirstHeading">
          Title or id
        </h1>
        [... stuff hidden ...]
      </tal:main-macro>
    </tal:hack>
  </metal:main>
  </body>
  </html>

That didn't hurt, did it?


Comment

Peter Bengtsson - 28th April 2005  [«« Reply to this]
Update. A consequence is that the title can become "index_html" which isn't very nice.
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.