在前面的基础上进行的修改,这样就可以跨域进行调用。
title.tpl.php
<?php$all_items = &$Planet->getItems();
$current_date = date('d/m/Y', time());
?>
var title='<div id="content"><h2>Today</h2><ul class="cheese">';<?php foreach ($all_items as $item): ?>
<?php
if (($item_date = date('d/m/Y',$item->getDate())) != $current_date){
$current_date = $item_date;
$t='</ul>';
$t.='<h2>'.$item_date.'</h2>';
$t.='<ul>';
echo 'title+="'.$t.'";';}
?>
<?php $owner = $item->getOwner(); ?>
<?php endforeach; ?>
title+="</ul></div>";
document.write(title);
注意JS里的变量赋值不能跨行。我在这儿吃了亏,调试了很长时间才发现。
这样就可以通过在页面上添加这个JS,随便哪个网站都能进行调用。
若有需要,还可以在这个基础上进行各种参数的定制,如最近多少个发言,发言的类型(标题或详细内容)等。