[Zope] Building multiple documents from fragments(objects).

Alan Young alany@idiglobal.com
Wed, 04 Apr 2001 10:23:19 -0600


Hello All,

I have some newbie questions.

I'm an experienced perl programmer trying to learn Zope/Python and am
trying to do something I know must be possible, but am having a hard
time wrapping my brain around this new way of doing things.

I have a bunch of document fragments with the following structure:

/docs
    fragment1
    fragment2
    fragment3
    ...
    doc1/
        index_html
    doc2/
        index_html

Currently, doc1/index_html and doc2/index_html have the following
structure:

<dtml-var standard_html_header>
<h1><dtml-var title_or_id></h1>

<div><h3>fragment1 title</h3>
 <ul>
  <li><dtml-var fragment1></li>
 </ul>
</div>

<div><h3>fragment2 title</h3>
 <ul>
  <li><dtml-var fragment2></li>
 </ul>
</div>

<div><h3>fragment3 title</h3>
 <ul>
  <li><dtml-var fragment3></li>
 </ul>
</div>

...

Is there a way that I can do something like this (warning: It's a clunky
mix of perl and dtml):

for my $f ( qw( fragment1 fragment2 fragment3 ) ) {
    <div><h3><dtml-var $f-title</h3>
        <ul>
            <li><dtml-var $f></li>
        </ul>
    </div>
}

I would prefer to do this entirely in dtml if at all possible (I need to
show non-programmers how to do this if I can make it work and they don't
wanna know about Python or Perl stuff).

Failing that, is there a way I can do this generically enough that a
designer could just use a dtml tag and pass the necessary values?

Thanks for your input.

Alan