Tyssen Posted May 3, 2014 Posted May 3, 2014 I have this in my template: function sponsor_row($group) { $output = 'test'; foreach($page->sponsors as $sponsor) : // if ($sponsor->sponsor_group->title == $group) : $output .= '<li> <a href="#"> <img src="'. $sponsor->sponsor_logo->url .'" alt=""> '. $sponsor->sponsor_title .' </a> </li>'; // endif; endforeach; return $output; } $outMain = sponsor_row(); What's getting printed out is 'test' and not the contents of the $output variable further down. I've verified the the foreach loop does output data (and in fact if I just type a string out for $output in the loop it still produces the same result), so why is only the first instance of $output being output?
teppo Posted May 3, 2014 Posted May 3, 2014 (edited) In function scope you'll have to use wire('page') or $wire->page instead of $page. Edited May 4, 2014 by teppo 2
kongondo Posted May 3, 2014 Posted May 3, 2014 In function scope you'll have to use wire('page') or wire->page instead of $page. A minor (but crucial) typo on second version; should be $wire->page 1
teppo Posted May 4, 2014 Posted May 4, 2014 A minor (but crucial) typo on second version; should be $wire->page Thanks, updated the post
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