opalepatrick Posted July 2, 2014 Posted July 2, 2014 I am trying to get an image to go along with my search results. I can create the image as a file but of course the path is incorrect as it refers to the search page itself. Any idea how I can reference the relevant assets file folder? foreach($matches as $m) { $img = $m->images->last->width(200); $out .= " <li> <img src='{$img}' /> <h4><a href='{$m->url}'>{$m->title}</a></h4> <p>{$m->summary}</p> </li> "; } Thanks again
Joss Posted July 2, 2014 Posted July 2, 2014 To start with, last should be last() (I think) So $img = $m->images->last()->width(200); Then you need to get the url for the image <img src='{$img->url}' /> The URL contains all the path data. 1
opalepatrick Posted July 2, 2014 Author Posted July 2, 2014 Thanks once again Joss. That worked a treat. The 'last' worked with and without the brackets, but I stuck them in just in case
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