2010-12-27

[BH] 文章更新時間

blogger 內建只會顯示文章的“發表時間”,卻沒有“更新時間”這個項目
為了做一些區別,“更新時間”這個東西似乎是有必要的
這樣對原本文章做修改才會有所記錄

在網路上找到 abin 大的文章,可以幫自己的文章加上更新時間

將以下 script 加到 <head></head> 裡面
<script type="text/javascript">
//<![CDATA[
<!-- Function used for generating the last update time for each post: showPostUpdateTime() -->
function showPostUpdateTime(json) {
  var updateTime = json.entry.updated.$t;
  var publishTime = json.entry.published.$t;
  if (updateTime.substr(0,10) != publishTime.substr(0,10))
    document.write(' | Updated at '+updateTime.substr(0,10)+' '+updateTime.substr(11,5));
}
//]]>
</script>


再將以下紅色的部份加到對應的位子就可以了
<span class='post-timestamp'>
  <b:if cond='data:top.showTimestamp'>
    <data:top.timestampLabel/>
    <b:if cond='data:post.url'>
      <a class='timestamp-link' expr:href='data:post.url' title='permanent link'><data:post.timestamp/></a>
      <!-- Fixed for display post update time -->
      <b:if cond='data:blog.pageType == "item"'>
        <script expr:src='"/feeds/posts/default/" + data:post.id + "?alt=json-in-script&callback=showPostUpdateTime"' type='text/javascript'/>
      </b:if>
    </b:if>
  </b:if>
</span>

我有做一些自己的修改
詳細的介紹就到 abin 大的網誌看吧

增加文章更新時間 (Show Post Update Time) by abin

沒有留言 :

張貼留言