New hack to improve your label/archive pages

Ngày 14 tháng 9 năm 2007
 
In a Blogger Beta blog, when you select a label or search for a term in the navbar, it displays the contents of all the posts that match the label/search in the main column. This is also true for archive pages for a particular month/year. As Ricardo rightly pointed out in my previous post, this is not very user-friendly if there are too many posts. Here's a new hack to display only the titles of matching posts (with their permalinks). You can then select the post(s) that you want to read and ignore others.

After my first hack to display labels in drop-down form, I spent some time understanding the various sections and widgets of Blogger Beta template. Here's a short introduction to widgets before giving you the code for my newhack. A section is a portion of the blog that consists of many widgets and each widget is associated with a hierarchy of data. For example, the following widget governs the display of blog's posts.


Here, data:posts is the list of posts associated with the "Blog" widget. As you can see, there is a loop going through each post. 'var' is the loop variable whose values are the various posts. For each post, it displays the date (if there's one) followed by the post contents. 'b:include' is the equivalent of a function call which is defined later. Then, there is an if condition that checks whether the page type is "item". This is so that comments are displayed only for item pages. This is just to give you an idea of widget code. For a detailed dissection, check out Scott's post.

Now, let's get back to the hack. Goto Edit HTML page, click on 'Expand Widget Templates' and replace the line in red above with the following lines.


Basically, I check whether the current page is not the main page or an item page. If it is neither, it must be a search page, label page or archive page. For such pages, I just display the post titles (linked to post URLs). Here, blog.homepageUrl is the equivalent of the old tag <$BlogURL$> and blog.pageType serves the purpose of .

You can try this hack by choosing a label in my blog's sidebar or clicking on the year 2006 in my archive display. If you like it, try it in your Beta blog and let me know your comments.

Update: I have explained how to override the limit of 20 posts per label page in this post.

Nguồn: hackosphere.blogspot.com

Nhãn: ,


 
Khi đăng lại bài viết này vui lòng ghi rõ nguồn http://www.kienthuctaichinh.com

 

Cảm ơn bạn đã ghé thăm kiến thức tài chính[.]com, hi vọng các bạn sẽ tìm thấy nhiều kiến thức bổ ích. Để tiết kiệm thời gian, bạn nên sử dụng tiện ích Tìm kiếm hoặc đọc bản tin RSS. Nếu bạn muốn theo dõi thường xuyên các bài viết hãy đăng ký nhận bản tin mới. Và nếu bạn có thắc mắc hay góp ý gì về các bài viết, xin hãy để lại nhận xét của mình bằng cách nhấp vào Gửi nhận xét của bạn. Xin cảm ơn!

Khuyến cáo: Mọi thông tin trên trang kienthuctaichinh.com được sửu tầm, tổng hợp từ các nguồn đáng tin cậy và chỉ mang tính tham khảo. Chúng tôi không chịu bất kỳ trách nhiệm nào về những hậu quả có thể xảy ra do sử dụng các thông tin của bài viết.

Các nhận xét về bài viết
Hiện tại
 

 


Đăng một Nhận xét

Bài viết cùng chủ đề:
Bài viết mới hơn:

Web kienthuctaichinh.com

 

 

  • Tài chính
  • Ngân hàng
  • Chứng khoán
 
q
b