Re: [Zope] ZPT contents slot

2005-06-22 Thread John Poltorak
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  ;-)... 
 
 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')::
 
divI'm a header/div
 
p tal:replace=structure context/CookedBody
  This is sample page content
/p
 
divI'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.

 
  --jcc
 -- 
 Building Websites with Plone
 http://plonebook.packtpub.com/
 
 Enfold Systems, LLC
 http://www.enfoldsystems.com


-- 
John


___
Zope maillist  -  Zope@zope.org
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 )


Re: [Zope] ZPT contents slot

2005-06-22 Thread J Cameron Cooper

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')::

  divI'm a header/div

  p tal:replace=structure context/CookedBody
This is sample page content
  /p

  divI'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
___
Zope maillist  -  Zope@zope.org
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 )


[Zope] ZPT contents slot

2005-06-21 Thread John Poltorak

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.

-- 
John




___
Zope maillist  -  Zope@zope.org
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 )


Re: [Zope] ZPT contents slot

2005-06-21 Thread J Cameron Cooper

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::

 divI'm a header/div

 p tal:condition=exists:context/stxfile
tal:replace=structure context/stxfile/CookedBody
   This is sample page content
 /p

 divI'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.


If you do not want the effects of acquisition, you may say instead::

  tal:condition=exists:context/aq_explicit/stxfile

since Zope assumes you generally want acquisition.

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

Enfold Systems, LLC
http://www.enfoldsystems.com
___
Zope maillist  -  Zope@zope.org
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 )


Re: [Zope] ZPT contents slot

2005-06-21 Thread John Poltorak
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::
 
   divI'm a header/div
 
   p tal:condition=exists:context/stxfile
  tal:replace=structure context/stxfile/CookedBody
 This is sample page content
   /p
 
   divI'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.

 
 If you do not want the effects of acquisition, you may say instead::
 
tal:condition=exists:context/aq_explicit/stxfile
 
 since Zope assumes you generally want acquisition.
 
   --jcc
 -- 
 Building Websites with Plone
 http://plonebook.packtpub.com/
 
 Enfold Systems, LLC
 http://www.enfoldsystems.com


-- 
John


___
Zope maillist  -  Zope@zope.org
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 )


Re: [Zope] ZPT contents slot

2005-06-21 Thread J Cameron Cooper

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::

 divI'm a header/div

 p tal:condition=exists:context/stxfile
tal:replace=structure context/stxfile/CookedBody
   This is sample page content
 /p

 divI'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')::

  divI'm a header/div

  p tal:replace=structure context/CookedBody
This is sample page content
  /p

  divI'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  -  Zope@zope.org
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 )