Skip to content

Instantly share code, notes, and snippets.

@ravixp
Last active July 12, 2017 17:22
Show Gist options
  • Select an option

  • Save ravixp/26d2ae1182dcd5782f827dad126bacb7 to your computer and use it in GitHub Desktop.

Select an option

Save ravixp/26d2ae1182dcd5782f827dad126bacb7 to your computer and use it in GitHub Desktop.
Magento 1: Check if H1 tag is existing on the product description. The client wants to add the H1 tag on the description in the certain products (magento backend). Change H1 to H2 in the page title if H1 found on the description.
<?php $product_description = $_helper->productAttribute($_product, $_product->getDescription(), 'description'); ?>
<?php if( strstr($product_description, '<h1') ) : // Check if H1 tag exists on the description ?>
<div class="page-title">
<h2 class="h1-page-title h1-title-exists-on-description">
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</h2>
</div><!--/.page-title -->
<?php else: // Check if H1 tag exists on the description ?>
<div class="page-title">
<h1 class="h1-title-NOT-found-on-description" itemprop="name">
<?php echo $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
</h1>
</div><!--/.page-title -->
<?php endif; // Check if H1 tag exists on the description ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment