marcin Posted December 18, 2010 Share Posted December 18, 2010 It's my method, probably Ryan will show a better one. if($page->child() instanceof NullPage) { // doesn't have } else { // has } Link to comment Share on other sites More sharing options...
ryan Posted December 18, 2010 Share Posted December 18, 2010 Hi Marcin, The method you posted is one I hadn't thought of before, but it would certainly work just as well as any other. Another variation on it would be: if($page->child()->id) { // has children } else { // does not have children } Here's the way that I usually do it. This is also what ProcessWire does before it executes the child() or children() methods, to decide whether a query should be executed: if($page->numChildren) { // has children } else { // doesn't have children } 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