<?php
$_title = '';
$_helper = $this->helper('catalog/output');
$_contentBlock = Mage::app()->getLayout()->getBlock('content');
if ($_contentBlock) {
    if ($_catalogView = $_contentBlock->getChild('category.products')) {
        // Products
        $_category = $_catalogView->getCurrentCategory();
        $_title = $_helper->categoryAttribute($_category, $_category->getName(), 'name');
    } else if ($_productView = $_contentBlock->getChild('product.info')) {
        // Product View
        $_product = $_productView->getProduct();
        $_title = $_helper->productAttribute($_product, $_product->getName(), 'name');
    } else if ($_pageBlog = $_contentBlock->getChild('page_blog_wrapper')) {
        // Page
        $_title = Mage::app()->getLayout()->getBlock('page_content_heading')->getContentHeading();
    }
}
?>
<?php if ($_title): ?>
<div class="@classNames">
    <div class="@containerInner">
        <h1><?php echo $_title ?></h1>
    </div>
</div>
<?php endif ?>
