当前位置: 首页>>代码示例>>PHP>>正文


PHP Posts::recent方法代码示例

本文整理汇总了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;
 }
开发者ID:vdanelia,项目名称:GeniXCMS,代码行数:13,代码来源:Rss.class.php

示例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;
 }
开发者ID:vdanelia,项目名称:GeniXCMS,代码行数:17,代码来源:Sitemap.class.php

示例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">
开发者ID:vdanelia,项目名称:GeniXCMS,代码行数:31,代码来源:rightside.php

示例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">
开发者ID:vdanelia,项目名称:GeniXCMS,代码行数:31,代码来源:dashboard.php


注:本文中的Posts::recent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。