Page 1 of 1

[solved] Cataloger - captions for item images?

Posted: Fri Aug 24, 2007 3:43 pm
by AmandaBTO
I'm using the Cataloger module for a clothing website and it's just about exactly what I want.  I especially love that the js for switching thumbnails with the big image is already there

But I'd like to display a caption for the thumbnails, like the colour the item is available in

I added as many item user defined attributes as images the user is allowed.  These captions are available in $attrlist the item sub template and I thought it'd be as easy as

Code: Select all

{section name=ind loop=$image_url_array}
<a href="javascript:repl('{$image_url_array[ind]}')"><img src="{$image_thumb_url_array[ind]}" title="{eval var=$attrlist[***].key}" /></a>
{/section}
The problem is that I need *** to be ind + 1 (because notes is the first value in $attrlist) but I don't know how to do that.  It just returns "Array[ind+1].key" for my title because it's taking ind+1 to be a literal value

Any ideas?
Thanks
amanda

Re: Cataloger - captions for item images?

Posted: Fri Aug 24, 2007 4:44 pm
by alby
AmandaBTO wrote: I'm using the Cataloger module for a clothing website and it's just about exactly what I want.  I especially love that the js for switching thumbnails with the big image is already there

But I'd like to display a caption for the thumbnails, like the colour the item is available in

I added as many item user defined attributes as images the user is allowed.  These captions are available in $attrlist the item sub template and I thought it'd be as easy as

Code: Select all

{section name=ind loop=$image_url_array}
<a href="javascript:repl('{$image_url_array[ind]}')"><img src="{$image_thumb_url_array[ind]}" title="{eval var=$attrlist[***].key}" /></a>
{/section}
The problem is that I need *** to be ind + 1 (because notes is the first value in $attrlist) but I don't know how to do that.  It just returns "Array[ind+1].key" for my title because it's taking ind+1 to be a literal value
Try with (untested, but look here):

Code: Select all

{section name=ind loop=$image_url_array}
<a href="javascript:repl('{$image_url_array[ind]}')"><img src="{$image_thumb_url_array[ind]}" title="$attrlist[$smarty.section.ind.index_next].key}" /></a>
{/section}
Alby

Re: Cataloger - captions for item images?

Posted: Fri Aug 24, 2007 4:57 pm
by AmandaBTO
You are my HERO!

Actual code is:

Code: Select all

...title="{eval var=$attrlist[$smarty.section.ind.index_next].key}"...
Thank you, thank you, thank you

Re: [solved] Cataloger - captions for item images?

Posted: Fri Aug 24, 2007 6:14 pm
by AmandaBTO
Just to add a bit more for anyone else who wants to do something like this...

If I didn't put pictures and captions in all available spots (ie 6 of 10), I'd get:
string(43) "Smarty error: eval: missing 'var' parameter"
for each empty spot

It's because as the section is going through the $image_url_array (with 10 elements) it eventually tries to reference beyond the end of the $attrlist array so I added an if statement to make sure $smarty.section.ind.index_next isn't more that's in $attrlist

Code: Select all

{section name=ind loop=$image_url_array}
    <div class="item_thumb">
    <a href="javascript:repl('{$image_url_array[ind]}')"><img src="{$image_thumb_url_array[ind]}" /></a>
{section name=attrTotal loop=$attrlist}{/section}
{eval var=$smarty.section.ind.index+1 assign=currImg}
{if $currImg < $smarty.section.attrTotal.total}
    {eval var=$attrlist[$smarty.section.ind.index_next].key}
{/if}
    </div>
{/section}

Re: [solved] Cataloger - captions for item images?

Posted: Fri Aug 24, 2007 7:25 pm
by alby
AmandaBTO wrote: Just to add a bit more for anyone else who wants to do something like this...

If I didn't put pictures and captions in all available spots (ie 6 of 10), I'd get:
string(43) "Smarty error: eval: missing 'var' parameter"
for each empty spot
Maybe it's better test if exist (untested always):

Code: Select all

... {if isset($attrlist[$smarty.section.ind.index_next].key)}title="{eval var=$attrlist[$smarty.section.ind.index_next].key}"{/if} ...
Alby