Jumat, 05 Juli 2013

Membuat Halaman Posting Dan Komentar dalam Tab View

Post And Comment On Tab View
Pernah saya menerapkan Halaman Posting Dan Komentar dalam Tab View pada blog ini namun menggunakan jQuery, kali ini saya akan membagikan TAB yang tidak menggunakan jQuery maupun Javascript. Ok, langsung saja berikut cara membuatnya, Untuk DEMO nya bisa dilihat diblog ini.

1. Cari kode ini : 
<!-- posts -->
<div class='blog-posts hfeed'>

<b:include data='top' name='status-message'/>
<data:defaultAdStart/>
<b:loop values='data:posts' var='post'>
<b:if cond='data:post.isDateStart'>
<b:if cond='data:post.isFirstPost == &quot;false&quot;'>
&lt;/div&gt;&lt;/div&gt;
</b:if>
</b:if>
<b:if cond='data:post.isDateStart'>
<div class="date-outer">
</b:if>
<b:if cond='data:post.dateHeader'>
<h2 class='date-header'><span><data:post.dateHeader/></span></h2>
</b:if>
<b:if cond='data:post.isDateStart'>
<div class="date-posts">
</b:if>
---------------------------------------------------------------------------
<div class='post-outer'>
<b:include data='post' name='post'/>
<b:if cond='data:blog.pageType == &quot;static_page&quot;'>
<b:include data='post' name='comment_picker'/>
</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<b:include data='post' name='comment_picker'/>
</b:if>
</div>
---------------------------------------------------------------------------
<b:if cond='data:post.includeAd'>
<b:if cond='data:post.isFirstPost'>
<data:defaultAdEnd/>
<b:else/>
<data:adEnd/>
</b:if>
<div class='inline-ad'>
<data:adCode/>
</div>
<data:adStart/>
</b:if>
</b:loop>
<b:if cond='data:numPosts != 0'>
</div></div>
</b:if>
<data:adEnd/>
</div>
Perhatikan kode yang saya beri garis putus2, Ganti kode tersebut dengan kode ini : 
<div class='post-outer'>
<div class='testsaja'>
<input checked='checked' id='s1' name='s' type='radio'/>
<input id='s2' name='s' type='radio'/>
<div class='tabs'>
<label for='s1'>Post</label>
<label for='s2'>Komentar</label>
</div>
<ul class='sections'>
<li><b:include data='post' name='post'/></li>
<li><b:if cond='data:blog.pageType == &quot;static_page&quot;'>
<b:include data='post' name='comment_picker'/>
</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<b:include data='post' name='comment_picker'/>
</b:if></li>
</ul></div></div>
Selanjutnya tambahkan kode ini diatas kode ]]></b:skin> 
input[type="radio"] {
left: -9999px;
position: absolute;
top: -9999px;
}
.tabs {
font-size: 0;
height: 27px;
position: relative;
white-space: nowrap;
z-index: 999;
}
.tabs label {
background: none repeat scroll 0 0 #EEEEEE;
border: 1px solid #DDDDDD;
color: #666666;
cursor: pointer;
display: inline-block;
font-size: 11px;
letter-spacing: 1px;
padding: 6px 20px;
text-transform: uppercase;
vertical-align: bottom;
}
.tabs label:first-child {
margin-left: 0;
}
.tabs label:hover {
background-color: #DDDDDD;
}
input:nth-child(1):checked ~ .tabs label:nth-child(1), input:nth-child(2):checked ~ .tabs label:nth-child(2), input:nth-child(3):checked ~ .tabs label:nth-child(3), input:nth-child(4):checked ~ .tabs label:nth-child(4) {
background: none repeat scroll 0 0 #FFFFFF;
box-shadow: none;
color: #000000;
padding: 6px 20px;
}
.sections {
}
.sections li {
display: none;
height: auto;
}
input:nth-child(1):checked ~ .sections li:nth-child(1), input:nth-child(2):checked ~ .sections li:nth-child(2), input:nth-child(3):checked ~ .sections li:nth-child(3), input:nth-child(4):checked ~ .sections li:nth-child(4) {
display: block;
}
Agar TAB tersebut tidak muncul di homepage tambahkan kode css ini diatas kode </head>
<b:if cond="data:blog.pageType != &quot;static_page&quot;">
<b:if cond="data:blog.pageType != &quot;item&quot;">
<style type="text/css">
.tabs
{display:none !important}
.sections li {display:block !important;}
</style>
</b:if>
</b:if>












0 komentar:

Posting Komentar