2009年4月29日星期三

在不改变修改过模板下增加打星评分功能

首先切换到 布局 的 修改HTML 项目,找到这行代码:

<div class='post-footer-line post-footer-line-1'>



在后面添加如下代码:

<b:if cond='data:blog.pageType == "item"'>



<span class='star-ratings'>


<b:if cond='data:top.showStars'>

<div expr:g:background-color='data:backgroundColor' expr:g:text-color='data:textColor' expr:g:url='data:post.absoluteUrl' g:height='42' g:type='RatingPanel' g:width='180'/>

</b:if>

</span>



</b:if>


接着往下面找到下列代码:




<!-- navigation -->

<b:include name='nextprev'/>



<!-- feed links -->

<b:include name='feedLinks'/>


最后跟在下面添加下列代码:




<b:if cond='data:top.showStars'>

<script src='http://www.google.com/jsapi' type='text/javascript'/>

<script type='text/javascript'>

google.load("annotations", "1");

function initialize() {

google.annotations.createAll();

google.annotations.fetch();

}

google.setOnLoadCallback(initialize);


</script>

</b:if>




就完工了!另外你注意到<script src='http://www.google.com/jsapi' type='text/javascript'/>这一行代码了吗?如果你已经加了<script src='http://www.google.com/jsapi' type='text/javascript'/>这行代码在博客开头的位置,那么可以把这行代码去掉,因为已经不需要了!

1 条评论:

匿名 说...

I like browsing your website for the reason that you can constantly bring us fresh and cool stuff, I feel that I should at least say a thank you for your hard work.

- Rob