Trang

Thứ Bảy, 5 tháng 4, 2014

ẨN HIỆN WIDGET Ở MỘT TRANG

Bước 1: Thêm một Widgets/Gadgets bất kì trong Blogger –Blogspot

Các bạn truy cập vào trang quản lý của Blogger, chọn blog muốn thực hiện thủ thuật này và chọn Bố cục (Layout). Tiếp tục chọn Thêm tiện ích (Add Gadgets), một cửa sổ sẽ hiện ra cho phép các bạn lựa chọn các tiện ích để thêm vào blogger. Ở đây tôi chọn tiện ích bài đăng phổ biến (Popular Post). Để nguyên mặc định và nhấn lưu. Bây giờ tiện ích bài đăng phổ biến đã được thêm vào blog của bạn.


Thêm Widgets - Gadgets trong Blogger
Thêm Widgets – Gadgets trong Blogger

Bước 2: Truy cập vào phần tùy chỉnh mẫu giao diện bằng cách nhấn vào mẫu và chọn Chỉnh sửa HTML

Chỉnh sửa html Blogger Template
Chỉnh sửa html Blogger Template

Bước 3: Trong mục Chuyển tới tiện ích hãy chọn Popular Post 1 hoặc Widget mà bạn đã thêm trước đó.

Sửa Code HTML cho Blogger Widgets
Sửa Code HTML cho Blogger Widgets

Bước 4: Click vào mũi tên ở đầu dòng để mở Code của tiện ích đó.

Hiển thị code HTML của các Widgets trong Blogger - Blogspot
Hiển thị code HTML của các Widgets trong Blogger – Blogspot
Chúng ta sẽ thấy Code của Widgets Popular Post 1 như sau:

Bước 5: Tùy chỉnh Ẩn – Hiện Widgets/Gadgets trong một trang hoặc một post bất kì

Để Widgets/Gadgets chỉ hiện ở trang chủ các bạn sẽ chỉnh sửa code như sau:

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.url == data:blog.homepageUrl’>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>
Hoặc:
<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “index”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>

Chỉ hiển thị Widgets tại trang xem bài viết

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “index”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>

Chỉ hiển thị Widgets tại một trang bất kì

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.url == “URL of the page”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>
Thay thế URL of the page bằng url của trang, bài viết mà bạn muốn widget sẽ hiển thị

Chỉ hiển thị Widgets tại những trang tĩnh – Static Page

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “static_page”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>

Ẩn Widgets tại trang tĩnh

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType != “static_page”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>

Ẩn Widgets tại một kiểu trang đặc biệt, ngoài loại trang đó các trang còn lại Widgets sẽ được hiển thị

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType != “index”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>
Thay index bằng các kiểu trang mà bạn muốn widgets ẩn đi (static_page, archive, item…)

Chỉ hiển thị Widgets tại trang lưu trữ

<b:widget id=’PopularPosts1′ locked=’false’ title=’Bài đăng phổ biến’ type=’PopularPosts’>
<b:includable id=’main’>
<b:if cond=’data:blog.pageType == “archive”‘>
<b:if cond=’data:title’><h2><data:title/></h2></b:if>
<div class=’widget-content popular-posts’>
<b:include name=’quickedit’/>
</div>
</b:includable>
</b:widget>
Trên đây là cách ẩn – hiện widgets tại một trang bất kì trong blogger – blogspot.
Do code quá dài nên ở phần sau mình thu gọn lại những phần không cần thiết để các bạn dễ theo dõi. Các bạn chỉ cần chú ý tới đoạn code được bôi màu đỏ và vị trí đặt đoạn code đó là đủ rồi. Hi vọng với thủ thuật nhỏ này các bạn sẽ có một giao diện blogger pro hơn.