[Zope] ZPT & contents slot

J Cameron Cooper zope-l at jcameroncooper.com
Wed Jun 22 13:18:25 EDT 2005


John Poltorak wrote:
> On Tue, Jun 21, 2005 at 04:46:55PM -0500, J Cameron Cooper wrote:
> 
>>John Poltorak wrote:
>>
>>
>>>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.
> 
> Really? 
> 
> You should try clicking on the drop down menu near the Add button of ZMI.
> That allows you to create a file  ;-)... 

That's a File, with a capital F. There's a difference.

>>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.
> 
> 
> I can't say I understood much of that, but this web page gave me an 
> example of exactly what I wanted to do:-
> 
> http://www.zopelabs.com/cookbook/1092772190
> 
> 
> Here is the code snippet which looks somewhat different to that which you 
> suggested, or is it basically the same?
> 
> <html>
> <body>
> 
> <!-- assume there is a file or other object containing structured
>      text, and it's called foobar. -->
> 
>  <span tal:define="stx python:modules['Products'].PythonScripts.standard.structured_text;
>                    the_text here/foobar"
>        tal:content="structure python:stx(the_text)">
> 
>     The structured text goes here.
> 
>  </span>
> 
> </body>
> </html>
> 
> 
> The problem is finding such examples, but at least in this instance I've 
> learnt something, so thanks for the help.

Essentially the same thing, save that you're using a library function to 
render some text, instead of asking an object to render itself.

		--jcc

-- 
"Building Websites with Plone"
http://plonebook.packtpub.com/

Enfold Systems, LLC
http://www.enfoldsystems.com


More information about the Zope mailing list