Okay, I've got this line:<br>
<div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000)); x iter/next"> <br>
and then use this kind of line several times further down and within the div:<br>
<input type="hidden" tal:attributes="value bitem/quantity; name python:'quantity_' + `x`"><br>
What this yields is lines like this:<br>
<input type="hidden" name="item_name_1" value="17x25"><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 <peter@fry-it.com><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. <br>
Instead of iterating over python:range(1000) do it on bitem_ids instead. <br>
<br>
You don't have to use a <br /> tag. You can use <br>
<input tal:attributes="value iter/number" /> <br>
if you want. <br>
You increment it by calling tal:iter/next whichever way you do it. <br>
<br>
<A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A> wrote: <br>
> 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: <br>
> > <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>
> > 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>
> > <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>
> > 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>
> > -----Original Message----- <br>
> From: Peter Bengtsson <<A href="mailto:peter@fry-it.com">peter@fry-it.com</A>> <br>
> To: <A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A> <br>
> Cc: <A href="mailto:zope@zope.org">zope@zope.org</A> <br>
> Sent: Mon, 30 Jul 2007 1:32 pm <br>
> Subject: Re: [Zope] Increment In PT? <br>
> > You can use the ZTUtils Iterator() > > <div tal:define="iter python:modules['ZTUtils'].Iterator(range(1000))"> > <br tal:define="dummy iter/next" tal:replace="iter/number" /> > <br tal:define="dummy iter/next" tal:replace="iter/number" /> > <br tal:define="dummy iter/next" tal:replace="iter/number" /> > </div> > > Which might give you some freedom such as iter/Roman or iter/odd > The above is practically the same as: > > <br tal:repeat="i python:range(3)" tal:replace="i" /> > > Generally, if you can, use a Python Script or something. The Iterator > is/was used in Plone templates to increment the tab index. > > <A href="mailto:tonylabarbara@aol.com">tonylabarbara@aol.com</A> <<A href="mailto:tonylabarbara@aol.com?">mailto:tonylabarbara@aol.com</A>> wrote: > > Hi; > > I´m trying to increment a variable in a page template. Here´s the > > general idea in my code: > > > <div metal:define-macro="main" tal:define="x python:0"> > > > <tal:block tal:define="x python:x + 1"> > > <td> > > <input type="hidden" tal:attributes="value item/name; name > > python:'item_name_' + `x`"> > > > > 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? > > TIA, > > Tony > > ------------------------------------------------------------------------ > > 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> > <<A href="http://www.aol.com/?ncid=AOLAOF00020000000437" target=_blank>http://www.aol.com/?ncid=AOLAOF00020000000437</A>>>. > > > > > ------------------------------------------------------------------------ > > > _______________________________________________ > > Zope maillist - <A href="mailto:Zope@zope.org">Zope@zope.org</A> <<A href="mailto:Zope@zope.org?">mailto:Zope@zope.org</A>> > > <A href="http://mail.zope.org/mailman/listinfo/zope" target=_blank>http://mail.zope.org/mailman/listinfo/zope</A> > > ** No cross posts or HTML encoding! ** > > (Related lists - > <A href="http://mail.zope.org/mailman/listinfo/zope-announce" target=_blank>http://mail.zope.org/mailman/listinfo/zope-announce</A> > > <A href="http://mail.zope.org/mailman/listinfo/zope-dev" target=_blank>http://mail.zope.org/mailman/listinfo/zope-dev</A> ) > > -- Peter Bengtsson, > work <A href="http://www.fry-it.com/" target=_blank>www.fry-it.com</A> <<A href="http://www.fry-it.com/" target=_blank>http://www.fry-it.com/</A>> > home <A href="http://www.peterbe.com/" target=_blank>www.peterbe.com</A> <<A href="http://www.peterbe.com/" target=_blank>http://www.peterbe.com/</A>> > hobby <A href="http://www.issuetrackerproduct.com/" target=_blank>www.issuetrackerproduct.com</A> <<A href="http://www.issuetrackerproduct.com/" target=_blank>http://www.issuetrackerproduct.com/</A>> > ------------------------------------------------------------------------ <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>
-- 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_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>