[ic] Multiple images...

Mike Heins interchange-users@interchange.redhat.com
Mon Aug 13 08:54:01 2001


Quoting JT Justman (ic@signless.com):
> Hi! My site is coming along nicely, thanks to a couple choice tidbits of
> help from the group. Thanks, guys, for being such a helpfull bunch!
> 
> Now my latest hitch: some of my products require only one (or zero) images,
> while others may require four or five. My plan is to name images based on
> SKU, and have IC show all that exist for a given SKU (i.e. 10002-01.jpg
> would be the second image of SKU 10002).
> 
> I could simply write as many [if file /location/(sku)-(n)] statements as I
> could imagine using, but I'd prefer a more eligant solution. I can't seem to
> get the hang of diong loops in IC, has anyone worked this out?

If this is just the flypage (you wouldn't want to do this on a list)
then you can grab one of the UI tags (undocumented) which does globbing.

[calc]
   my $spec = q{__DOCROOT____IMAGE_DIR__/items/[item-code]*};
   my @files = $Tag->list_glob($spec);
   for(@files) {
        s:^__DOCROOT__::;
   }
   $Scratch->{img_files} = join "\n", @files;
   return;
[/calc]

<XMP>
[loop list="[scratchd img_files]*"]
    <IMG SRC="[loop-code]">
[/loop]
</XMP>

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

Unix version of an Outlook-style virus:
It works on the honor system. Please forward this message to everyone
you know, and delete a bunch of your files at random.