martind Posted October 11, 2012 Share Posted October 11, 2012 why does an if statement like this not work as expected... if($input->urlSegment2 OR !isset($page)) ... i try to execute different php-code in my head.inc for direct page calls (if this ist the right term, www.domain.tld/entry/page-name/ where template "entry" uses the $page array) and such that make use of urlSegments with infos for $pages->find in a different template. What i`m doing wrong? Link to comment Share on other sites More sharing options...
diogo Posted October 11, 2012 Share Posted October 11, 2012 This won't work because the $page variable will always be set. If you want to test for the existence of segments, this will be enough if($input->urlSegment1) Link to comment Share on other sites More sharing options...
martind Posted October 11, 2012 Author Share Posted October 11, 2012 hm, but how can I make a distinction like this? if(isset($page)) { $parent_page = $page->parent; }else{ $parent_page = $input->urlSegment2; } Link to comment Share on other sites More sharing options...
arjen Posted October 11, 2012 Share Posted October 11, 2012 I think you can check against $page->id instead of $page. 1 Link to comment Share on other sites More sharing options...
martind Posted October 11, 2012 Author Share Posted October 11, 2012 I think you can check against $page->id instead of $page. ah, of course. Thank you arjen, this works. Link to comment Share on other sites More sharing options...
martind Posted October 11, 2012 Author Share Posted October 11, 2012 I think you can check against $page->id instead of $page. mhm, no, works only for a if true condition. but if(!$page instanceof NullPage) did it. Link to comment Share on other sites More sharing options...
arjen Posted October 11, 2012 Share Posted October 11, 2012 That should work. To minimize the code you can also try to turnaround the statement using an ifnot (!). if (!$page->id) { // do stuff } 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