moonmoon的修改

为了可以更好的给其他网站调用,对现在的moonmoon进行了一定的修改,使之可以通过js进行调用,也可以直接通过页面调用。
1. index.php
添加了:

elseif (array_key_exists('type', $_GET) && $_GET['type'] == 'title'){

//Serve full cache content

header('Content-type: text/html; charset=UTF-8');

if (!OutputCache::Start('title', $first_item_url, $output_cache)) {

include_once(dirname(__FILE__).'/custom/tpl/title.tpl.php');

OutputCache::End();

}

}
elseif (array_key_exists('type', $_GET) && $_GET['type'] == 'content'){

//Serve full cache content

header('Content-type: text/html; charset=UTF-8');

if (!OutputCache::Start('content', $first_item_url, $output_cache)) {

include_once(dirname(__FILE__).'/custom/tpl/content.tpl.php');

OutputCache::End();

}

}

2. 增强了两个对应的tpl文件
titile.tpl.php

<?php

$all_items = &$Planet->getItems();

$current_date = date('d/m/Y', time());

?>
<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;

echo '</ul>';

echo '<h2>'.$item_date.'</h2>';

echo '<ul>';

}

?>

<?php $owner = $item->getOwner(); ?>

<li>

<a href="<?php echo $owner->getWebsite(); ?>"><?php echo $owner->getName(); ?></a> :

<a href="<?php echo $item->getUrl(); ?>" title="Go to original place"><?php echo $item->getTitle(); ?></a>

</li>

<?php endforeach; ?>

</ul>

</div>

content.tpl.php

<?php

$all_items = &$Planet->getItems();

$limit = $PlanetConfig->getMaxDisplay();

$count = 0;

?>

<div id="content">

<?php foreach ($all_items as $item): ?>

<div class="post">

<h2 class="post-title"><a href="<?php echo $item->getUrl(); ?>" title="Go to original place"><?php echo $item->getTitle(); ?></a></h2>

<p class="post-info">

<?php echo $item->getAuthor(); ?>,

<?php

$ago = time() - $item->getDate();

echo '<span title="'.Duration::toString($ago).' ago">'.date('d/m/Y', $item->getDate()).'</span>';

?> |

<?php $owner = $item->getOwner(); ?>

<a href="<?php echo $owner->getWebsite(); ?>"><?php echo $owner->getName(); ?></a>

</p>

<div class="post-content">

<?php echo $item->getContent(); ?>

</div>

</div>

<?php if (++$count == $limit) { break; } ?>

<?php endforeach; ?>

</div>

3. 使用方法
若需要调用title的显示方法:index.php?type=title
若需要调用content的显示:index.php?type=content

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 6AtwEc to the field below:

以新浪微博帐号登录