js调用moonmoon

在前面的基础上进行的修改,这样就可以跨域进行调用。
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(); ?>

title+='<li> : </li>';

<?php endforeach; ?>

title+="</ul></div>";
document.write(title);

注意JS里的变量赋值不能跨行。我在这儿吃了亏,调试了很长时间才发现。
这样就可以通过在页面上添加这个JS,随便哪个网站都能进行调用。
若有需要,还可以在这个基础上进行各种参数的定制,如最近多少个发言,发言的类型(标题或详细内容)等。

This entry was posted in Linux and tagged , , . Bookmark the permalink.

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string oIhcI7 to the field below:

以新浪微博帐号登录