[Zope3-Users] Rendering subobjects in pages
Frank Burkhardt
fbo2 at gmx.net
Mon Aug 6 08:42:07 EDT 2007
Hi,
On Mon, Aug 06, 2007 at 09:51:18AM -0230, Greg Baker wrote:
> How can I specify a template to render a sub-object within one of my content
> objects?
>
> For example, pretend I have a Contact object which contains a Person object.
> I am rendering the Contact object through a page template.
>
> class Contact:
> person = Person()
>
> In all the examples I see, rendering the person would be done using many tal
> expressions like <span tal:content="context/person/name" /> or something
> similar.
>
> Is it possible to render the person object using a single tal expression, <div
> tal:content="context/person" />,
You may use a view which adapts Person() objects:
<div tal:content="structure context/person/@@defaultview" />
You have to define e view for Person() like this:
*browser/configure.zcml*
[...]
<page
for="..interfaces.IPerson"
name="defaultview"
template="mypersontemplate.pt"
[...]
/>
[...]
Don't forget to allow access to you Person()-class (e.g. via configure/class/allow).
[snip]
Regards,
Frank
More information about the Zope3-users
mailing list