-
Notifications
You must be signed in to change notification settings - Fork 8
Home
Vova Yatsyuk edited this page Jan 20, 2016
·
26 revisions
- Edit the link
href
andclass
attributes in template source - Use the external javascript to add the onclick observers
- Using public events to call javascript on tab activate or deativate
- Disable native tabs in Magento 1.9 RWD theme
- Reccuring info tab
- Dynamic tab titles
- Unset multiple blocks
There are two possible ways to implement this feature:
<a href="#TAB_ALIAS_FROM_BACKEND" class="easytabs-anchor easytabs-scroll easytabs-animate">Description</a>
For Example, the link below will activate the description tab:
<a href="#product_tabs_description_tabbed" class="easytabs-anchor easytabs-scroll easytabs-animate">Description</a>
$$('WRITE_SELECTOR_HERE').first()
.observe('click', function(e) {
e.stop();
var element = e.element(),
tab = 'review',
scroll = true,
animate = true;
easytabs.onclick(element , e, tab, scroll, animate);
});
For example, the code below shows how to add onclick event to the Write Review
and Read Reviews
links:
$$('.rating-links a, .no-rating a').each(function(el) {
el.observe('click', function(e) {
e.stop();
easytabs.onclick(el, e, 'review', true);
if (el.href.indexOf('#review-form') > -1) {
$('review-form') && $('review-form').scrollTo();
}
});
});
There are four public events are available to listen:
- easytabs:beforeActivate
- easytabs:afterActivate
- easytabs:beforeDeactivate
- easytabs:afterDeactivate
Example:
document.observe('easytabs:afterActivate', function(e) {
var tab = e.memo.tab, // string
content = e.memo.content, // dom element
easytabs = e.memo.easytabs; // easytabs instance
console.log(tab + ':' + easytabs.getActivationCount(tab));
});
There 3 ways of dealing with native tabs:
.product-view .tabs { display: none; }
Find the following lines and remove them:
<div class="product-collateral toggle-content tabs">
<?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
<dl id="collateral-tabs" class="collateral-tabs">
<?php foreach ($detailedInfoGroup as $alias => $html):?>
<dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
<dd class="tab-container">
<div class="tab-content"><?php echo $html ?></div>
</dd>
<?php endforeach;?>
</dl>
<?php endif; ?>
</div>
Find the following lines:
<div class="product-collateral toggle-content tabs">
<?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?>
<dl id="collateral-tabs" class="collateral-tabs">
<?php foreach ($detailedInfoGroup as $alias => $html):?>
<dt class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></dt>
<dd class="tab-container">
<div class="tab-content"><?php echo $html ?></div>
</dd>
<?php endforeach;?>
</dl>
<?php endif; ?>
</div>
and replace them with:
<div class="product-collateral">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
<?php if (in_array($alias, array('reviews'))) : continue; endif; // use this to skip some tabs ?>
<div class="box-collateral <?php echo "box-{$alias}"?>">
<?php if ($title = $this->getChildData($alias, 'title')):?>
<h2><?php echo $this->escapeHtml($title); ?></h2>
<?php endif;?>
<?php echo $html; ?>
</div>
<?php endforeach;?>
</div>
Create new tab with following configuration:
General Details
- Title:
Recurring Profile
- Alias:
recurring_info
- Block Type:
Custom Block
- Sort Order:
10
- Status:
Enabled
Widget Options
- Block:
payment/catalog_product_view_profile
- Template:
payment/catalog/product/view/profile/schedule.phtml
- Unset(reference::block_alias):
product.info::recurring_info
Use eval
directive to call block methods in tab title.
Block | Dynamic Tab Title |
---|---|
Tags | Tags ({{eval code="getCount()"}}) |
Reviews | Reviews ({{eval code="getReviewsCollection()->count()"}}) |
Askit | Questions ({{eval code="getCount()"}}) |
Use comma to unset multiple block from layout.
Examples:
parent_block1::block_to_unset1,parent_block2::block_to_unset2
right::catalog.product.related,product.info::related_products