Jump to content

[Solved] Pull selected pages from page field for classes


louisstephens
 Share

Recommended Posts

This might be a completely dumb question, but I cant seem to wrap my head around it. I have a page reference field that allows users to select "Tags". In the front end I would like to use the titles as class names for a single item. ie:

<?php $previews = $pages->find("template=preview"); ?>
<?php foreach($previews as $preview): ?>
	<div class="tagOne TagTwo tagThree"> <!-- use another foreach to output-->
		<img src="<?=$preview->preview_image->url; ?>" />
	</div>
<?php endforeach; ?>

I am little stumped as I know I need a foreach loop to produce each tag title, but how do I insert them all into one corresponding div class with spaces?

Whelp, that was the easiest thing, but my brain just didnt "get it". Just put the foreach in the "class" inside of the overall foreach. Ugh ?

Link to comment
Share on other sites

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
 Share

×
×
  • Create New...