$node
isn't available on user pages. But when $showpage
is set, you are checking a property on the $node
object. This gets the two errors you are describing.
I'm not sure what you are trying to do but you can troubleshoot by breaking out your booleans. I find it helpful to break logic onto multiple lines whenever possible, so that other people (and I) can read it later.
From:
if (((!empty($node)) || (!empty($showpage))) && (($node->type != 'article') && ($node->type != 'basic_page'))):
To:
if (!empty($node) || !empty($showpage)) {
if ($node->type != 'article' && $node->type !='basic_page') {
// do that stuff
}
}
So - when $showpage
is not empty but $node
is, as on a user page, $node is undefined.
I'm not exactly sure what you are trying to do but I think it is along the lines of "show this stuff on node pages that are not basic page and not article, or when the $showpage variable is present.
In which case:
if ((!empty($node) && !in_array($node->type, array('article', 'basic_page'))) || !empty($showpage))
Or more readably,
if(function_exists('views_get_page_view') && views_get_page_view() || arg(0) == 'user') {
$showpage = 'yes';
}
elseif (!empty($node) && !in_array($node->type, array('article', 'basic_page'))) {
$showpage = 'yes';
}
if (!empty($showpage)) {
// do that stuff
}
It isn't a one-liner, but the longer code is easier to read, troubleshoot, and prevent errors.