Tyssen Posted May 3, 2014 Share 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? Link to comment Share on other sites More sharing options...
teppo Posted May 3, 2014 Share 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 Link to comment Share on other sites More sharing options...
Tyssen Posted May 3, 2014 Author Share Posted May 3, 2014 Ah, right. Thanks, all good now. Link to comment Share on other sites More sharing options...
kongondo Posted May 3, 2014 Share 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 Link to comment Share on other sites More sharing options...
teppo Posted May 4, 2014 Share Posted May 4, 2014 A minor (but crucial) typo on second version; should be $wire->page Thanks, updated the post 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