[albatross-users] Trying to work around pagnation with cols issue...
Matt Goodall
matt at pollenation.net
Mon Jun 23 10:42:31 EST 2003
On Sun, 2003-06-22 at 23:51, Michael C. Neel wrote:
> Currently Albatross doesn't support pagesize and cols in the same al-for
> tag, and I'm trying towork around this by grouping my results into cols
> and using two al-for tags for the output. It's not working, and I'm not
> sure why.
>
> Here is the page_process for the section I'm testing with:
>
> photos =
> ['One','Two','Three','Four','Five','Six','Seven','Eight','Nine']
> ctx.locals.photos = []
> # We now must make ctx.locals.photos be a list of (up to) 3
> element lists of photos
> # this is because albatross doesnot support pagnation with a
> cols attrib
> temp = []
> for pht in photos:
> temp.append(pht)
> if len(temp) == 3:
> ctx.locals.photos.append(temp[:]) # [:] is an
> explict copy
> temp = []
> if len(temp):
> ctx.locals.photos.append(temp[:]) # [:] is an explict
> copy
A slightly nicer way of writing this might be:
photos = [...]
ctx.locals.photos = []
i = 0
while 1:
row = photos[i:i+3]
if not row: break
ctx.locals.photos.append(row)
i = i+3
But that wasn't the question ;-)
>
> And then in my template file:
>
> <table>
> <al-for expr="photos" iter="row" pagesize="2">
> <tr>
> <al-for expr="row.value()" iter="cell">
> <al-exec expr="pht = cell.value()">
> <td align="center"><al-value expr='pht' noescape>
> </td>
> </al-for>
> </tr>
> </al-for>
> </table>
> <table>
> <tr>
> <al-form method="POST">
> <td>
> <al-if expr="row.has_prevpage()">
> <al-input type="submit" prevpage="row" value="<<"
> name="photo_prev">
> </al-if>
> </td><td align="right">
> <al-if expr="row.has_nextpage()">
> <al-input type="submit" nextpage="row" value=">>"
> name="photo_next">
> </al-if>
> </td>
> </al-form>
> </tr>
> </table>
>
> The next button does appear, but clicking it doesn't advance to the next
> page.
Hmm. I can't see anything wrong. I've tried the above code here and it
works ok with Albatross 1.10pre1. The name="photo_prev" and
name="photo_next" attributes are redundant since they are generated by
the tag but that doesn't seem to matter.
What type of app (stateful/random, session in form/file/server etc) are
you writing and what version of Albatross are you using?
- Matt
--
Matt Goodall
Pollenation Internet Ltd, http://www.pollenation.net
e: matt at pollenation.net
More information about the Albatross-users
mailing list