All about Magento E-commerce Store.......MagentoForum: Changing Product Tabs from JavaScript to CSS

Tuesday, July 12, 2011

Changing Product Tabs from JavaScript to CSS

Search engines typically only read visible page content. This poses a problem with some Magento Themes product view page. With Magento themes (built around the Modern theme) the Product Description, We Also Recommend, Additional Information, and Product Tabs are embedded using JavaScript. While some feel this is a more visually appealing look, the search engines don't.
Amazon.com is a great example of an ecommerce site that uses visible page promotional content to its marketing advantage. Product pages on Amazon are LONG and nothing is hidden behind tabs or embedded in JavaScript product tabs. This leaves more promotional content for the search engines to index. Having the product page content indexed is a must for any ecommerce site hoping to take advantage of organic search.

First, from the admin section go to system/configuration then drill down to the store level for the Configuration Scope and select the advanced/developer menu. Turn on Template path hints under the Debug tab.
Second, from the frontend choose a product page and verify that the tabs are infrontend/default/hellopress/template/catalog/product/view/tabs.phtml.
Then open the tabs.phtml file and around lines 33-46 you should see:
01.<ul class="tabs">
02.<?php foreach ($this->getTabs() as $_index => $_tab): ?>
03.<?php if($this->getChildHtml($_tab['alias'])): ?>
04.<li id="product_tabs_<?php echo $_tab['alias'] ?>" <?php echo !$_index ?'class="active first"' '' ?>><a href="#"><?php echo $_tab['title']?></a></li>
05.<?php endif; ?>
06.<?php endforeach; ?>
07.</ul>
08.<div class="padder">
09.<?php foreach ($this->getTabs() as $_index => $_tab): ?>
10.<?php if($this->getChildHtml($_tab['alias'])): ?>
11.<div id="product_tabs_<?php echo $_tab['alias'] ?>_contents">
12.<?php echo $this->getChildHtml($_tab['alias']) ?></div>
13.<?php endif; ?>
14.<?php endforeach; ?>
15.</div>
Change it to:
01.<ul>
02.<?php foreach ($this->getTabs() as $_index => $_tab): ?>
03.<?php if($this->getChildHtml($_tab['alias'])): ?>
04.<li style="margin-bottom:10px;width:100%;"><div class="tabs_new"><?phpecho $_tab['title']?></div>
05.<div><?php echo $this->getChildHtml($_tab['alias']) ?></div></li>
06.<?php endif; ?>
07.<?php endforeach; ?>
08.</ul>
09.<div class="padder">
10.<?php foreach ($this->getTabs() as $_index => $_tab): ?>
11.<?php if($this->getChildHtml($_tab['alias'])): ?>
12.<?php endif; ?>
13.<?php endforeach; ?>
14.</div>
This removes the JavaScript tabs and defines them with CSS class .tabs_new
In Boxes.css you can add .tabs_new anywhere but around line 153ish is the most relevant place.
1..tabs_new {
2.margin-bottom:10px;
3.line-height:2em;
4.background:url(../images/tabs_bg.gif) repeat-x 0 100% #f2f2f2;
5.font-size:15pt;
6.font-weight:bold;
7.}
You can define the CSS product tabs anyway you see fit to match your current themes style. This will change tabs from something like this:
img1
To something like this:
img2
I hope you find the benefits to this as helpful as I have.
Good Luck and Happy Ecommerce!

No comments:

Post a Comment