Personal tools
You are here: Home Documentation Manuals Archetypes Developer Manual A simple AT Product Adding a custom view to the skin
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

2.8. Adding a custom view to the skin

Up one level
Now, providing the template that overrides Archetypes's default base_view, in the 'skins/instantmessage' subdirectory.

To provide a custom view for your content type, add a page template called 'instantmessage_view.pt' in the 'skins/instantmessage' directory with the following code:

<html metal:use-macro="here/main_template/macros/master"
      i18n:domain="plone" >
<body>

<div metal:fill-slot="main"
     tal:define="priority here/getPriority;
                 priority_color python:test(priority == 'high', 'red', priority == 'low', 'green', '')" >

        <h1 tal:content="context/Title"
            tal:attributes="style string:color:$priority_color" >
          Title
        </h1>

        <p tal:content="structure here/getBody" />          

        <div class="documentByLine">
          Message by <span tal:content="context/Creator" /> 
          with <strong tal:content="priority" /> priority.
          -
          <span tal:replace="python:here.toLocalizedTime(context.CreationDate(),long_format=1)" />
        </div>
    
</div>

</body>
</html>

After the product installation step, which we still have to discuss (see later), Plone should be able to find this template and use it as the content object's default view when you invoke the content's URL.

Python notes:

  • The new methods we use on the content object (getPriority, getBody, etc), called the "accessors", are generated by Archetypes as part of its internal mechanisms, based on the field definition in the content schema ; so if the field is called 'priority', there is a generated method called 'getPriority' responsible to return the stored value on the object. Note that the code of the method is not available somewhere for modification ; "generated" here means it is available in the server's memory, within Archetypes engine's registries, when the Zope server has started.

by Kamon Ayeva last modified November 7, 2008 - 22:58
Contributors: Sisi Nutt, Alexander Limi, Martin Aspeli, Marco De Vitis, Raphael Ritz, Maik Röder, Steve McMahon
All content is copyright Plone Foundation and the individual contributors.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by