I’m creating a gallery using FF Matrix and would like segment_4 to set which photo is displayed. I’m doing the following:
{myImages limit="1" offset="{segment_4}"}
{imageUrl}
{/myImages}This however means that the url: mysite.com/photos/my-gallery/0 will show image no. 1 and mysite.com/photos/my-gallery/5 will show image no. 4 etc.
I’d really like the URL to match the image number something like the following would work but it doesn’t.
{myImages limit="1" offset="{exp:simple_math calculate='{segment_4}-1'}"}
{imageUrl}
{/myImages}I’ve seen examples using row_count to show a single image but this means the code has to loop through all the images, not as efficient
If you turn on PHP on input mode you can achieve the “minus one” math that way.
{myImages limit="1" offset="{exp:simple_math calculate='<?={segment_4}-1;?>'}"}
{imageUrl}
{/myImages}Give that a shot and see if it works.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.