Skip to content

Instantly share code, notes, and snippets.

@traviswaelbro
Created December 14, 2015 17:31
Show Gist options
  • Save traviswaelbro/0ef032ddcd3e93b66944 to your computer and use it in GitHub Desktop.
Save traviswaelbro/0ef032ddcd3e93b66944 to your computer and use it in GitHub Desktop.
Update to Magento /catalog/category/view.phtml template that allows admin to specify a different h1 in the description to override the default "category name" as h1. In our application, this allows us to use SEO-specific phrasing on the category page, while using more user-friendly names for the navigation menu, etc.
<div class="page-title category-title">
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
<a href="<?php echo $this->getRssLink() ?>" class="link-rss"><?php echo $this->__('Subscribe to RSS Feed') ?></a>
<?php endif; ?>
<?php // Display normal category name as h1 unless there is an h1 set in the category description ?>
<?php if( $_description=$this->getCurrentCategory()->getDescription() ) { ?>
<?php if(strpos( $_helper->categoryAttribute($_category, $_description, 'description'), "h1" ) !== false) { ?>
<?php } else { ?>
<h1 class="test"><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php } ?>
<?php } else { ?>
<h1><?php echo $_helper->categoryAttribute($_category, $_category->getName(), 'name') ?></h1>
<?php } ?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment