Okay, I've got this line:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000)); x iter/next"&gt; <br>
and then use this kind of line several times further down and within the div:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type="hidden" tal:attributes="value bitem/quantity; name python:'quantity_' + `x`"&gt;<br>
What this yields is lines like this:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;input type="hidden" name="item_name_1" value="17x25"&gt;<br>
but it never increments! And I have 3 items! How do I get it to increment?<br>
TIA,<br>
Tony<br>
<br>
<br>
-----Original Message-----<br>
From: Peter Bengtsson &lt;peter@fry-it.com&gt;<br>
To: tonylabarbara@aol.com<br>
Cc: zope@zope.org<br>
Sent: Mon, 30 Jul 2007 1:52 pm<br>
Subject: Re: [Zope] Increment In PT?<br>
<br>


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