Problem with breadcrumb on forum I am using Drupal 7, and I want to show the breadcrumb only on the forum, so I used the following code:

$node = menu_get_object();
if (arg(0) == 'forum' || $node-&gt;type == 'forum') print $breadcrumb;


The code works, but it gives errors when I visit the admin page.


  Notice: Trying to get property of non-object in include() (line 18 of /srv/www/lusciousanime.com/public_html/sites/all/themes/anime/page.tpl.php).


Does anyone know how to fix it?
That is because, when you visit a page that is not a node page, menu_get_object() (when called without arguments) doesn't return any value. The function could not return any value in other cases too, or not return an object, if the load function returns FALSE, as the code executed from the function is the following one.

  $router_item = menu_get_item($path);
  if (isset($router_item['load_functions'][$position]) &amp;&amp; !empty($router_item['map'][$position]) &amp;&amp; $router_item['load_functions'][$position] == $type . '_load') {
    return $router_item['map'][$position];
  }


Your code should be similar to the following one:

$node = menu_get_object();

if (arg(0) == 'forum' || (!empty($node) &amp;&amp; $node-&gt;type == 'forum')) {
  print $breadcrumb;
}