martind Posted October 11, 2012 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?
diogo Posted October 11, 2012 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)
martind Posted October 11, 2012 Author 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; }
arjen Posted October 11, 2012 Posted October 11, 2012 I think you can check against $page->id instead of $page. 1
martind Posted October 11, 2012 Author Posted October 11, 2012 I think you can check against $page->id instead of $page. ah, of course. Thank you arjen, this works.
martind Posted October 11, 2012 Author 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.
arjen Posted October 11, 2012 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 }
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