Jonathan Posted December 29, 2014 Share Posted December 29, 2014 It's late so forgive me if I make no sense. context: This is for a film database How can I pull a specific image from another page based on a selection from the current page? So, I am selecting a classification/rating for the film (e.g PG) - this works great and I am outputting the title of the selected page on the front-end. On each of the classification pages, I created an image field for a single image and uploaded the respective classification image/logo. Here's the code I used to echo the page title: <?php $rating = $page->classification; echo "<a href='{$rating->url}'>{$rating->title}</a>"; I thought I'd be able to echo the image by adding: <img src='{$rating->image}'> but no such luck. Thanks in advance! J Link to comment Share on other sites More sharing options...
Joss Posted December 29, 2014 Share Posted December 29, 2014 Make sure the image field is set to 1 image only, otherwise it will be an array. You have taken the right route to get to the image field, though you don't really need to set up a separate $rating variable. $page->classification->image_field, and then add ->url to output the url echo "<img src='{$page->classification->image_field->url}' alt='{$page->classification->title}'>"; 4 Link to comment Share on other sites More sharing options...
Jonathan Posted January 2, 2015 Author Share Posted January 2, 2015 Thanks Joss! 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