title: how to get category name of current product (on product detail page) in magento
body: <p>I used following codes but didn't work for this case:</p>
  
  <pre><code>$_category_detail=Mage::registry('current_category');
  echo $_category_detail-&gt;getName();
  </code></pre>
  
  <p>got <strong>Fatal error:</strong> Call to a member function getName() on a non-object in /app/design/frontend/base/default/template/catalog/product/view.phtml</p>
  
  <p>we make some filters and use below mention code in head.phtml:</p>
  
  <pre><code>$is_product = Mage::registry('product');
  
  if($is_product){ 
  
    if(is_object(Mage::registry('current_category'))){ 
      $category_name = Mage::registry('current_category')-&gt;getName(); 
    }
    else{ $category_name = ""; }
  
  }
  </code></pre>
  
  <p>But this only works if you go from a category to a product. If you visit the product page directly nothing is being displayed</p>