Skip to content. | Skip to navigation

Personal tools
You are here: Home Members kurt Plone Programming Tutorial METALprogrammingguide

METALprogrammingguide

A basic description of METAL syntax and a brief intro on how Plone renders pages.

METAL Syntax


Macros

Macros let you define blocks of code that can be called by other page templates.

metal:define-macro
Lets say I created a page template in "context/mypagetemplate" and defined a macro called "Special"
...
<div metal:define-macro="Special">
* Special Stuff *
</div>
...

metal:use-macro
Now I want to use it in another page, so I call its path and access boxA under that page's macros property.
<div metal:use-macro="context/mypagetemplate/macros/Special">
What ever is here will be replaced with "* Special Stuff *" and it will include the outer div as well.
</div>

Or, If I want to use the macro in the same page it was, all I need is...
<div metal:use-macro="Special">
What ever is here will be replaced with "* Special Stuff *"
</div>


Slots

Slots let you use macros, but leave holes in them for other things to fill in.  You must use slots inside of macros.  Macros are kind of like a function/method and slots are like arguments.

metal:define-slot
<div metal:define-macro="Special">
<div metal:define-slot="what">
...
</div>
</div>

metal:fill-slot
<div metal:use-macro="context/mypagetemplate/macros/Special">
<div metal:fill-slot="what">
This is what!  This is what will be placed on the page!
</div>
</div>


OTHER STUFF

I am still trying to figure out what bodytext, cssslot and etc are.   Other wewb metal syntax guides only metion macros and slots as described above.

It may be that these two are equivalent but I am not sure...

<metal:cacheheaders define-macro="cacheheaders">
...
</metal:cacheheaders>

-or-

<div metal:define-macro="cacheheaders">
...
</div>
 

metal:block  ???
metal:bodytext  ??

metal:cssslot  ??

metal:cacheheaders ??


Here is an example from "The Definitive Guide to Plone"  it makes no sense... How can one define a slot inside of the fill-slot?  It seems this would recurse forever...
<metal:cssslot fill-slot="css_slot">
<metal:cssslot define-slot="css_slot" />
</metal:cssslot>

Document Actions
« November 2009 »
November
MoTuWeThFrSaSu
1
2345678
9101112131415
16171819202122
23242526272829
30