John Poltorak wrote:
On Tue, Jun 21, 2005 at 03:16:11PM -0500, J Cameron Cooper wrote:
John Poltorak wrote:
If I create a macro which defines a slot called 'content', is there
any way to have that slot populated by a file with a specific name
if it exists in a folder?
What I'd like to do is create a structure text file, in each of the
folders A B C and have it automatically loaded into a content slot
of a master template whenever the options A B C are selected.
Can I do that, and if so how?
I have spent all day looking at ZPT references and have no idea if
what I'd like to do is possible.
You don't have to involve macros::
<div>I'm a header</div>
<p tal:condition="exists:context/stxfile"
tal:replace="structure context/stxfile/CookedBody">
This is sample page content
</p>
<div>I'm a footer</div>
If 'stxfile' can be aquired, what it renders will be included as page
structure. (You may need to use a different method one the end of the
path to render the object; for Documents, this is 'CookedBody'.)
Otherwise, nothing will be rendered, though you could add a block
with the oposite condition to supply a default action.
Is 'stxfile' the actual filename? I'm not concerned about it being
structured initially - just want to see it working in principle with
any file containg some text.
It's the name of an object. I made up this name for your "structure text
file, in each of the folders A B C". You may call it as you will.
Note: there is no such thing as a "file" in the ZODB. Everything is an
object.
This is how "content" is viewed. One thing I forgot to mention: you
would apply this template (say it's named 'special_view') to your
folders, like:
http://localhost/A/special_view
http://localhost/B/special_view
http://localhost/C/special_view
Now, if we used a template like this (let's name it 'direct_view')::
<div>I'm a header</div>
<p tal:replace="structure context/CookedBody">
This is sample page content
</p>
<div>I'm a footer</div>
we could apply it like so::
http://localhost/A/stxfile/direct_view
http://localhost/B/stxfile/direct_view
http://localhost/C/stxfile/direct_view
This is a much more typical pattern, at least for content. If you want
to apply a wrapper to page templates, then you use macros.
--jcc
--
"Building Websites with Plone"
http://plonebook.packtpub.com/
Enfold Systems, LLC
http://www.enfoldsystems.com
_______________________________________________
Zope maillist - [email protected]
http://mail.zope.org/mailman/listinfo/zope
** No cross posts or HTML encoding! **
(Related lists -
http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )