Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Image Position for Template


Go to End


2 Posts   1598 Views

Avatar
Sajan

Community Member, 13 Posts

6 February 2016 at 1:34pm

Hi guys,

I understand that you can capture an image position by calling $Pos in your template.

What i need to do is capture the image position and subtract 1 from it and have this value echo'd in my template, how can i do this?

So for example:
I have 3 images with the current positions 1, 2, 3 respectively - if i call $Pos it will echo these position correctly
However i need to subtract 1 from each so that in my template their positions display as 0, 1, 2

Thanks
Sajan

Avatar
Sajan

Community Member, 13 Posts

6 February 2016 at 1:45pm

Worked it out! Just had to pass an argument of 0 to it - the argument tells the function where to start counting from for the position

Ie. $Pos(0)

:D