Thursday, January 10, 2008

Hướng dẫn tạo thêm cột (sidebar) cho Blog

Tạo thêm cột(sidebar) cho blog như thế nào? là một câu hỏi được đặt ra với rất nhiều "new blogger". Nếu bạn muốn việc tạo thêm cột trở nên dễ dàng tôi khuyên bạn hãy sử dụng template Minima vì nó có cấu tạo khá đơn giản. Trong bài viết này tôi sẽ sử dụng template Minima, các bạn hãy xem hướng dẫn dưới đây và có thể làm tương tự với template của mình.

Dưới đây là hình ảnh bạn có thể thấy trong Page Elements của template Minima:












Tạo thêm cột cho template gồm 2 bước:

1) Đặt tên và quy định các đặc tính vật lý cho sidebar :

Các bạn hãy xem đoạn code dưới đây:

#outer-wrapper {
width: 660px;
margin:0 auto;
padding:10px;
text-align:$startSide;
font: $bodyfont;
}

#main-wrapper {
width: 410px;
float: $startSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

#sidebar-wrapper {
width: 220px;
float: $endSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

Bạn sẽ thực hiện bước 1 trong đoạn code này.

outer-wrapper : Bao gồm header, main, sidebar và footer. Ở đoạn mã trên, ta có thể thấy chiều rộng (width) của outer, mainsidebar lần lượt là: 660px, 410px, 220px. Nếu bạn muốn thêm 1 sidebar nữa bạn cần nới rộng outer . Các đơn vị độ dài ở đây bạn có thể sử dụng là : px và % .
Tôi sẽ cho thay đổi chiều rộng của outer, mainsidebar lần lượt là: 100% , 48% , 23%. Sau đó đặt đoạn code sau đây xuống dưới đoạn code trên:

#newsidebar-wrapper {
width: 23%;
float: $endSide;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

Đến đây thôi vẫn chưa xong bước 1. Nếu bạn muốn đặt các bài viết của bạn ở giữa và 2 sidebar nằm 2 bên bạn cần thay đổi thuộc tính Float của chúng. Tôi sẽ thay đổi thuộc tính Float của main, sidebar và newsidebar lần lượt là: left, right, left. Để thay đổi khoảng cách giữa các sidebar và main bạn cần thêm các thuộc tính Margin và padding. Bạn có thể đọc bài viết Tìm hiểu Margin và Padding" để biết cách sử dụng chúng.

Sau khi đã thêm các thuộc tính đó bạn sẽ có đoạn code như sau:

#outer-wrapper {
width: 100%;
margin:0 auto;
padding:10px;
text-align:$startSide;
font: $bodyfont;
}

#main-wrapper {
width: 48%;
float: left;
margin:0 0 0 20px;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

#sidebar-wrapper {
width: 23%px;
float: right;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

#Newsidebar-wrapper {
width: 23%;
float:left;
word-wrap: break-word; /* fix for long text breaking sidebar float in IE */
overflow: hidden; /* fix for long non-text content breaking IE sidebar float */
}

2) Xác định vị trí của sidebar

Bạn hãy tìm đến đoạn code sau:

<div id='main-wrapper'> <b:section class='main' id='main' showaddelement='no'> <b:widget id='Blog1' locked='true' title='Blog Posts' type='Blog'/> </b:section> </div>

Còn đây là đoạn code bạn cần chèn vào trong template của mình:

<div id='newsidebar-wrapper'> <b:section class='Newsidebar' id='Newsidebar' preferred='yes'/> </div>

Nếu bạn muốn phần bài viết (main) nằm giữa 2 sidebar bạn phải chèn đoạn code mầu xanh lên trên đoạn code mầu đỏ. Nếu bạn muốn đổi vị trí của newsidebar với main tức là newsidebar nằm giữa main và sidebar, bạn chỉ cần đổi lại vị trí 2 đoạn code trên là được.

Sau đó bạn tìm đến 2 đoạn code sau:

#header-wrapper {
width:660px;
margin:0 auto 10px;
}

và :

#footer {
width:660px;

clear:both;
margin:0 auto;

padding-top:15px;

line-height: 1.6em;
text-transform:uppercase;
letter-spacing:.1em;
text-align: center;

}


Bạn thay đổi chiều rộng của header và footer từ 660px thành 100% . Save lại và mở Page Elements, bạn sẽ thấy:












Vậy là bạn có thể tự tạo cho mình 1 template 3 cột rồi đó. Nếu bạn muốn template của mình có 4 cột, bạn cũng làm bước 1 nhưng cần chỉnh lại chiều rộng của main, sidebar, newsidebar và ở bước 2 bạn có thể đặt code của sidebar mới lên trên hoặc ngay dưới code của newsidebar cũng được.


Cám ơn các bạn đã theo dõi bài viết. Mong sẽ nhận được nhiều ý kiến đóng góp từ các bạn để giúp hoàn thiện nội dung bài viết hơn..
Chúc các bạn có 1 ngày vui vẻ!










AdSense Earning = Impression-count x Click-though-rate x Cost-per-click x smart-pricing-factor.impression count is basically referring to increase your traffic. It means the number of times AdSense secret block is displayed.Click-through-rate (CTR) is ratio of clicks per impressions. It can range from 0.1% to 30%, but most commonly around 1% to 10%.Cost-per-click (CPC) is the earning money you get per click. While traditionally it refers to the amount advertisers pay for each click, it can also mean the amount publishers get for each click.Smart-pricing is AdSense method to determine how valuable clicks from your site is worth. If clicks on your site doesn’t provide good value to advertisers, e.g. from visitors’ geo-location that seldom translate to sales, you will only get a fraction of the supposed CPC.Don’t encourage your visitors to click on ads. The only acceptable text is “Sponsored Links” and “Advertisements”.When in doubt don’t hesitate to contact the AdSense team. They are very helpful.Use Overture Bid Tool and Search Engine Keyword Tool to find suitable keyword.Submit your URL to search engines for crawling.Google is not the only search engine. Optimize for different engines as well. You are very likely to face less competition than in Google.Search engines are where most of your new visitors come from. Learn a bit about Search Engine Optimization, or pay people to do it. Doing it yourself will save yourself from troubles created by not-so-honorable SEO (Search Engine Optimizer).Try 300×250 medium rectangle, 336×280 large rectangle, or 160×600 wide skyscraper ad formats. These are the best performing AdSense ad formats.Wrap the AdSense block around your content.AdSense have both CPM (cost per thousand impressions) and CPC (cost per click) ads, and will choose the one it thinks can perform better.Adsense tips have in here.SearchAdSense Tipson Google. Most webmasters continuously try to optimize their AdSense and many are more than willing to share their result.You can get help of other AdSense pulishers at AdSense Help Group.Remove the “Advertise on this sitefrom your AdSense block until your site is big enough to attract real advertisers. This will help to clear off many MFA (made-for-adsense) sites. You can disable it from AdSense account setting.Use AdSense Competitive Ads Filter to remove irrelevant ads.Try variations of AdSense colors, format, position on different pages to make it more unpredictable for your visitors.Watch your AdSense tips earning. Notify AdSense hack Team if you find anything suspicious. Your competitors might try to sabotage your account, or your well-meaning friend keep on clicking on the ads thinking they are helping you.Use Google AdSense section targeting to help AdSense deliver more relevant ads.Let earning money!money!


2 comments:

Tài chính doanh nghiệp said...

Bài viết được đấy Hiệp ơi, cảm ơn nhiều nhé.

http://haitvonline.blogspot.com

Anonymous said...

bai viet hay lam! ban co the huong dan minh cach chen nhc nen vao blog ko?
cam ow truoc nhe!