Tyssen Posted June 6, 2014 Share Posted June 6, 2014 I'm working on a site where a photographer creates a series of image entries and then uses another 'layout' entry to group images for presentation. So in the layout entry, there's fields for full width image, image left, image right, smaller images etc and the photographer can select image entries. In my template I have: foreach($entries as $entry) : if($entry->image_full) : $outMain .= '<div class="full">'; $full = $pages->get($entry->image_full); $outMain .= $full->title; $outMain .= '</div>'; endif; endforeach; This outputs the wrapping div but not any of the contents. If I replace $full = $pages->get($entry->image_full) with an actual entry ID it works. So how do I select the page based on the value of the page fieldtype? :? Link to comment Share on other sites More sharing options...
SiNNuT Posted June 6, 2014 Share Posted June 6, 2014 What's your code for getting $entries? Link to comment Share on other sites More sharing options...
Tyssen Posted June 6, 2014 Author Share Posted June 6, 2014 $entries = $pages->find('parent=/layouts'); Link to comment Share on other sites More sharing options...
SiNNuT Posted June 6, 2014 Share Posted June 6, 2014 Seeing as you already have a PageArray ($entries) i am a bit confused what you try to do with $full = $pages->get($entry->image_full); Couldn't you just delete the $full line and just do $outMain .= $entry->title; I think i don't exactly understand how you have put together the logic behind the image entries (pages with 1 or more images??) and layout entries. What kind of field is image_full? Link to comment Share on other sites More sharing options...
Tyssen Posted June 6, 2014 Author Share Posted June 6, 2014 $entry->title outputs Row 1 which is the name of the layout entry, rather than the title of the image entry. I'm trying to give the site owner a way of grouping groups of images (each which is a link to a modal which then contains a full gallery of images). Sometimes they want a single image full width, sometimes they want a tall image left with two smaller images right, and sometimes the opposite. So my idea was they create a series of image entries which each have a title where they can upload all the images, and they can also add tags too. Then there's the layout entries which has four page select fields: one for choosing a single full width image entry, one for choosing a single tall, left-aligned image entry, one for choosing a single tall, right-aligned image entry, and one for choosing two smaller image entries. So the template loops through all the layout entries and outputs a wrapping div for each one. I then want to output the data from the pages that are selected with the page select fields within each entry. Does that make more sense? Link to comment Share on other sites More sharing options...
SiNNuT Posted June 6, 2014 Share Posted June 6, 2014 Are you sure your page fields belonging to the layout entries are set to single page (see the details tab of the fields). If so you should be able to directly do: // assuming that you actually want to output the title of the page that holds the single image echo $entry->image_full->title; So if($entry->image_full) echo "<div class='full'>$entry->image_full->title</div>"; 1 Link to comment Share on other sites More sharing options...
Tyssen Posted June 6, 2014 Author Share Posted June 6, 2014 Ah, right, I was making things far more complex than they needed to be. That works fine, thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now