Skip to content

Instantly share code, notes, and snippets.

@MGCodeSnips
Created December 6, 2016 09:39
Show Gist options
  • Save MGCodeSnips/c6dc0daffdaac9d293bbcd34c2c198fd to your computer and use it in GitHub Desktop.
Save MGCodeSnips/c6dc0daffdaac9d293bbcd34c2c198fd to your computer and use it in GitHub Desktop.
You can use this code to add tab boxes to any product page. here you will find CSS body and js
/* Style for tabs. */
<style>
/*** product tabs ***/
#productTabs {
margin: 20px 0 0;
position: relative;
}
/* shadetabs */
.shadetabs {
text-transform: uppercase;
position: relative;
top: 1px;
}
.shadetabs li a {
position: relative;
padding: 10px 20px;
border: 1px solid [ekm:colour_1][/ekm:colour_1];
border-bottom: none;
color: #fff;
background-color: [ekm:colour_1][/ekm:colour_1];
display: block;
}
.shadetabs li a:hover {
text-decoration: none;
background-color: #333;
}
.shadetabs li a.selected {
color: #666;
background-color: #fff;
border-color: #eee;
}
.shadetabs li a.selected:hover {background-color: #fff;}
/* tab div content */
#tab-div {
background-color: #fff;
padding: 20px;
border: 1px solid #eee;
}
.tabcontent {display: none;}
/********** end product page styles **********/
/* customer reviews */
#customer-reviews > p:first-child {margin-top: 0;}
#customer-reviews > p:last-child {margin-bottom: 0;}
.review {
padding: 10px 0;
border-top: 1px solid #eee;
}
.review-left {
float: left;
width: 140px;
}
.review-left .name,
.review-left .reviewer-location {margin-bottom: 5px;}
.review-right {
float: right;
width: 540px;
}
</style>
/* put this in the description div */
<div id="productTabs">
<ul id="countrytabs" class="shadetabs">
<li class="ib"><a href="#" rel="country1" class="selected">Description</a></li>
[ekm:customerreviews]
show='auto';
editbuttonposition='right';
id='auto';
html_before='<li class="ib"><a href="#" rel="country2">Reviews</a></li>';
html_review='';
html_no_reviews='';
html_after='';
limit='10';
orderby='date ASC';
[/ekm:customerreviews]
</ul>
<div id="tab-div">
<div id="country1" class="tabcontent">
[ekm:productdescription]
font_formatting='no';
[/ekm:productdescription]
</div>
[ekm:customerreviews]
show='auto';
editbuttonposition='right';
id='auto';
html_before='
<div id="country2" class="tabcontent">
<div id="customer-reviews">
<p><a href="[url]">Write an online review</a> and share your thoughts with other shoppers!</p>
';
html_review='
<span class="cf">
<div class="review ib cf">
<div class="review-left">
<div class="name">[reviewer]</div>
<!-- review name -->
<div class="reviewer-location">[location]</div>
<!-- review location -->
<div class="stars">
<img src="/ekmps/designs/assets/master/1304/images/[star-value]-stars[ekm:industry_variant_name]space_replace='-';[/ekm:industry_variant_name].png">
</div>
<!-- review stars -->
</div>
<!-- review left -->
<div class="review-right">[review]</div>
<!-- review right -->
</div>
<!-- review container -->
</span>
<!-- cf -->
';
html_no_reviews='
<p>Be the first to <a href="[url]">review this product</a></p>
<!-- no reviews -->
';
html_after='
</div>
<!-- customer reviwes -->
</div>
<!-- country2 -->
';
limit='10';
[/ekm:customerreviews]
<!-- customer reviews -->
</div>
<!-- tab div -->
</div>
<!-- productTabs -->
/* put all this at the end of the page */
<script src="/ekmps/designs/assets/master/1304/Other/tabcontent.js"></script>
<script>
$j(window).ready(function(){
$j("#productTabsTabs li").click(function(){
var curIndex = $j(this).index();
$j("#productTabsTabs li.selected").removeClass("selected");
$j("#productTabsContent .tabCont.selected").removeClass("selected");
$j(this).addClass("selected");
$j("#productTabsContent .tabCont").eq(curIndex).addClass("selected");
});
});
var countries=new ddtabcontent("countrytabs")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
// remove br tags after product options
$j(".main-product-options").children("br").remove();
$j(".back-in-stock:empty").hide();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment