本文整理匯總了PHP中Posts::recent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Posts::recent方法的具體用法?PHP Posts::recent怎麽用?PHP Posts::recent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Posts
的用法示例。
在下文中一共展示了Posts::recent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
public static function create($url = 'post', $type = 'post', $count = '20')
{
$posts = Posts::recent($count, $type);
header("Content-Type: text/xml");
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$xml .= "\n <rss version=\"2.0\">\n <channel>\n <title>" . Site::$name . "</title>\n <link>" . Site::$url . "</link>\n <description>" . Site::$desc . "</description>\n ";
foreach ($posts as $p) {
# code...
$xml .= "\n <item>\n <title>" . $p->title . "</title>\n <link>" . Url::$url($p->id) . "</link>\n <description>" . substr(strip_tags(Typo::Xclean($p->content)), 0, 260) . "</description>\n </item>\n ";
}
$xml .= "\n </channel>\n </rss>\n ";
echo $xml;
}
示例2: create
public static function create($url = "post", $type = 'post', $class = 'Url')
{
$posts = Posts::recent(20, $type);
header("Content-Type: text/xml");
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$xml .= "\n <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n ";
//print_r($posts);
if (!isset($posts['error'])) {
# code...
foreach ($posts as $p) {
# code...
$xml .= "\n <url>\n <loc>" . $class::$url($p->id) . "</loc>\n </url>\n ";
}
}
$xml .= "\n </urlset>\n ";
echo $xml;
}
示例3: foreach
?>
</h5>
<p><em><?php
echo Options::get('siteslogan');
?>
</em>
<?php
echo Site::$desc;
?>
</p>
</div>
<div class="sidebar-module">
<h4>Recent Post</h4>
<ol class="list-unstyled">
<?php
$recent = Posts::recent(10);
$num = Db::$num_rows;
if ($num > 0) {
foreach ($recent as $r) {
# code...
echo "<li><a href=\"" . Url::post($r->id) . "\">{$r->title}</a></li>\n ";
}
} else {
echo "No Post to Show";
}
?>
</ol>
</div>
<div class="sidebar-module">
<h4>Elsewhere</h4>
<ol class="list-unstyled">
示例4: foreach
<div class="row">
<?php
echo Hooks::run('admin_page_dashboard_action', $data);
?>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-file-text-o"></i> <?php
echo LATEST_POST;
?>
</h3>
</div>
<div class="panel-body">
<ul class="list-group">
<?php
$post = Posts::recent(5, 'post');
//print_r($post);
if (isset($post['error'])) {
echo "<li class=\"list-group-item\">{$post['error']}</li>";
} else {
foreach ($post as $p) {
# code...
echo "\n <li class=\"list-group-item\">\n <a href=\"" . Url::post($p->id) . "\" target=\"_blank\">\n {$p->title} \n </a>\n <small class=\"badge\">{$p->author}</small>\n \n </li>";
}
}
?>
</ul>
</div>
</div>
</div>
<div class="col-md-6">