Jump to content

Recommended Posts

Posted

Hi everyone,

I would like to target the last image in the fieldset and apply a specific class to it. How would I do that?

I've tried this and it applies it to all:

if(($page->images->last()->name) == 'whatsnext.png') { echo $whatsnextclass; }

It's not targeting that specific image, it's just checking to see if that exists. I don't know how else to go about this. Help please?

Thanks!

Posted

This should do what you want

//inside a foreach($page->images as $image)
if($page->images->last() === $image) { echo $whatsnextclass; }

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...