Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How do I change the category heading tags to <h1>
 
Malcom Media
Jr. Member
 
Avatar
Total Posts:  21
Joined:  2008-07-28
Dallas, TX
 

I am trying to change my category headings from <h2> to <h1> tags and I must be doing something wrong… I’m a novice.

I edited both view.phtml and page.phtml in this directory: app/design/frontend/default/default/template/catalog/category/

I changed in page.phtml:

<div class="page-head-alt">
    <
h2><?php echo $this->getTitle() ?></h2>
</
div>
<
div>
    
<?php echo $this->getContent() ?>
</div>

to:

<div class="page-head-alt">
    <
h1><?php echo $this->getTitle() ?></h1>
</
div>
<
div>
    
<?php echo $this->getContent() ?>
</div>

and in the view.phtml file:

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php 
if($this->isContentMode()): ?>
    
<div class="category-head">
    
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        
<a href="<?php echo $this->getRssLink() ?>" class="link-feed right"><?php echo $this->__('Subscribe to RSS Feed'?></a>
    
<?php endif; ?>
    
<h2><?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?></h2>
    </
div>

to this:

<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<?php 
if($this->isContentMode()): ?>
    
<div class="category-head">
    
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        
<a href="<?php echo $this->getRssLink() ?>" class="link-feed right"><?php echo $this->__('Subscribe to RSS Feed'?></a>
    
<?php endif; ?>
    
<h1><?php echo $this->htmlEscape($this->getCurrentCategory()->getName()) ?></h1>
    </
div>

The category headings are still displaying as <h2>. Did I edit the wrong files? What am I missing?

 
Magento Community Magento Community
Magento Community
Magento Community
 
tempus fugit
Jr. Member
 
Avatar
Total Posts:  20
Joined:  2008-03-09
UK
 

in view.phtml there are six occurrences of setting h2 for the category heading.
It runs a query and you can set it differently according to whether the category has been set to display products only, static blocks only, product and static blocks.

If you change all six to h1 that should do it!
(Of course you can tailor the heading setting differently for each of those display types if you wish)

Doesn’t seem necessary to edit page.phtml

I didn’t need to do anything with cacheing, but remember to fully refresh the web pages that you are viewing and checking e.g. Ctrl+F5

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rooni
Sr. Member
 
Total Posts:  87
Joined:  2009-03-25
England
 

Hello there in my case i have only changed one line in view.phtml and it perectly changed the h2 tag to h1

Use this when you are not using any static block within that page

<?php endif; ?>
    
<h1><?php echo $_helper->categoryAttribute($_category$this->htmlEscape($this->getCurrentCategory()->getName()), 'name'?></h1>

And if you are using static block the change this:

<div class="category-head">
    
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        
<a href="<?php echo $this->getRssLink() ?>" class="link-feed right"><?php echo $this->__('Subscribe to RSS Feed'?></a>
    
<?php endif; ?>
    
<h2><?php echo $_helper->categoryAttribute($_category$this->htmlEscape($this->getCurrentCategory()->getName()), 'name'?></h2>
    </
div>
to:
<div class="category-head">
    
<?php if($this->IsRssCatalogEnable() && $this->IsTopCategory()): ?>
        
<a href="<?php echo $this->getRssLink() ?>" class="link-feed right"><?php echo $this->__('Subscribe to RSS Feed'?></a>
    
<?php endif; ?>
    
<h1><?php echo $_helper->categoryAttribute($_category$this->htmlEscape($this->getCurrentCategory()->getName()), 'name'?></h1>
    </
div>

hope this work for you, also if you change all h2 tags to h1 they will work as well.

Regards,
Haroon

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top