Bryan Green
Bryan Green

Reputation: 521

SilverStripe Using Field Values in Template

all! So I'm brand-spankin' new to SilverStripe, and while I've had success in modifying the 'Gallery' module to include an option to set the thumbnail size, I'm having issues using the thumbnail width/height values in my template. The code below does not show any of the gallery images (if I hardcode a width and height, such as 250,250 they display)-- but after the loop where I display the $ThumbWidth and $ThumbHeight values, those are displaying just fine...so I know those values are available to the template.

<% loop OrderedImages %>
        <a class="fancybox" data-fancybox-group="gallery" href="$Filename" title="$Caption">
                $SetSize($ThumbWidth, $ThumbHeight)
        </a>
<% end_loop %>
Width: $ThumbWidth&nbsp;
Height: $ThumbHeight

So apparently, the $SetSize function is not liking the values I'm passing to it. Can someone shed some light on where my mistake is?

Thanks! Bryan

Upvotes: 1

Views: 114

Answers (1)

Bryan Green
Bryan Green

Reputation: 521

From the SilverStripe forum:

Those variables are not set on the OrderedImage item which is the context of the loop. Use $Top.ThumbWidth and $Top.ThumbHeight as parameters.

Upvotes: 3

Related Questions