<div>I would think this should be pretty easy in the PT itself, given what you've shared so far. But I'm still not quite there. Here's what I've got:</div>
<div> </div>
<span tal:repeat="bitem_id bitem_ids" tal:omit-tag=""><br>
<div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000))"> <br>
<br tal:define="x iter/next" tal:replace="iter/number" /><br>
<div><br>
Now, I don't really want that <br /> tag there, because it's printing a number to screen that I don't want there. However, it only prints the number "1" twice, once for each product, when it should print 1 then 2, I would think. (I presume I should just take the tal:replace out and leave the definition, but it's still not incrementing!) Later in the script I have this:<br>
<br>
<input type="hidden" tal:attributes="value item/name; name python:'item_name_' + `x`"><br>
<input type="hidden" tal:attributes="value item/id; name python:'item_number_' + `x`"><br>
<br>
and other similar lines. What I'm trying to effectuate is that the "x" gets replaced with an incremented number. Can you help just a little more?<br>
TIA,<br>
Tony<br>
<br>
-----Original Message-----<br>
From: Peter Bengtsson <peter@fry-it.com><br>
To: tonylabarbara@aol.com<br>
Cc: zope@zope.org<br>
Sent: Mon, 30 Jul 2007 1:32 pm<br>
Subject: Re: [Zope] Increment In PT?<br>
<br>
</div>
<div id=AOLMsgPart_0_ead64ef0-a9a6-49b7-ac82-1a08bae09e94 style="FONT-SIZE: 12px; MARGIN: 0px; COLOR: #000; FONT-FAMILY: Tahoma, Verdana, Arial, Sans-Serif; BACKGROUND-COLOR: #fff">You can use the ZTUtils Iterator() <br>
<br>
<div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000))"> <br>
<br tal:define="dummy iter/next" tal:replace="iter/number" /> <br>
<br tal:define="dummy iter/next" tal:replace="iter/number" /> <br>
<br tal:define="dummy iter/next" tal:replace="iter/number" /> <br>
</div> <br>
<br>
Which might give you some freedom such as iter/Roman or iter/odd <br>
The above is practically the same as: <br>
<br>
<br tal:repeat="i python:range(3)" tal:replace="i" /> <br>
<br>
Generally, if you can, use a Python Script or something. The Iterator is/was used in Plone templates to increment the tab index. <br>
<br>
<A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A> wrote: <br>
> Hi; <br>
> I´m trying to increment a variable in a page template. Here´s the > general idea in my code: <br>
> > <div metal:define-macro="main" tal:define="x python:0"> <br>
> > <tal:block tal:define="x python:x + 1"> <br>
> <td> <br>
> <input type="hidden" tal:attributes="value item/name; name > python:'item_name_' + `x`"> <br>
> > > Now, all of that works...once. That is, it increments from 0 to 1, but > not from 1 to 2! Each time I pass through the td element, I need it to > increment. I tried putting the tal definition in the td, but then it > didn´t even increment once! What do? <br>
> TIA, <br>
> Tony <br>
> ------------------------------------------------------------------------ <br>
> AOL now offers free email to everyone. Find out more about what's free > from AOL at *AOL.com* <<A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank>http://www.aol.com?ncid=AOLAOF00020000000437</A>>. <br>
> > > ------------------------------------------------------------------------ <br>
> > _______________________________________________ <br>
> Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A> <br>
> <A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope</A> <br>
> ** No cross posts or HTML encoding! ** <br>
> (Related lists - > <A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A> <br>
> <A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> ) <br>
<br>
-- Peter Bengtsson, <br>
work <A href="http://www.fry-it.com/" target=_blank>www.fry-it.com</A> <br>
home <A href="http://www.peterbe.com/" target=_blank>www.peterbe.com</A> <br>
hobby <A href="http://www.issuetrackerproduct.com/" target=_blank>www.issuetrackerproduct.com</A> <br>
</div>
<!-- end of AOLMsgPart_0_ead64ef0-a9a6-49b7-ac82-1a08bae09e94 --><div class="AOLPromoFooter">
<hr style="margin-top:10px;" />
AOL now offers free email to everyone. Find out more about what's free from AOL at <a href="http://www.aol.com?ncid=AOLAOF00020000000437" target="_blank"><b>AOL.com</b></a>.<br />
</div>