Jump to content

Getting the first child in a loop


caribou
 Share

Recommended Posts

Edit: Never mind. Simple typo on the equal signs. Carry on!

Hello! I am trying to use $child->first() inside a loop, but I get the error "Error:Call to a member function first() on a non-object" Any pointer on what I'm doing wrong? Thanks!

foreach($page->children->find("sort=-markerdate") as $child) {
	$current = $child->first();
	if($child = $current){
		$icon = $child->parent->icon->url;
	}else{
		if ($child->icon != ""){
			$icon = $child->icon->url;
		}else{
			$icon = "image.png";
		}
	}
}
  • Like 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...