本文整理汇总了PHP中Posts::list_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::list_all方法的具体用法?PHP Posts::list_all怎么用?PHP Posts::list_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::list_all方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
public static function generate()
{
// create a dom xml object
static::$document = new DOMDocument('1.0', 'UTF-8');
// create our rss feed
$rss = static::element('rss', null, array('version' => '2.0', 'xmlns:atom' => 'http://www.w3.org/2005/Atom'));
static::$document->appendChild($rss);
// create channel
$channel = static::element('channel');
$rss->appendChild($channel);
// title
$title = static::element('title', Config::get('metadata.sitename'));
$channel->appendChild($title);
// link
$url = 'http://' . $_SERVER['HTTP_HOST'];
$link = static::element('link', $url);
$channel->appendChild($link);
// description
$description = static::element('description', Config::get('metadata.description'));
$channel->appendChild($description);
// laguage
// http://www.rssboard.org/rss-language-codes
$language = static::element('language', Config::get('application.language', 'en'));
$channel->appendChild($language);
$ttl = static::element('ttl', 60);
$channel->appendChild($ttl);
$docs = static::element('docs', 'http://blogs.law.harvard.edu/tech/rss');
$channel->appendChild($docs);
$copyright = static::element('copyright', Config::get('metadata.sitename'));
$channel->appendChild($copyright);
// atom self link
$atom = static::element('atom:link', null, array('href' => $url, 'rel' => 'self', 'type' => 'application/rss+xml'));
$channel->appendChild($atom);
// articles
$params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc');
foreach (Posts::list_all($params) as $post) {
$item = static::element('item');
$channel->appendChild($item);
// title
$title = static::element('title', $post->title);
$item->appendChild($title);
// link
$url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug);
$link = static::element('link', $url);
$item->appendChild($link);
// description
$description = static::element('description', $post->description);
$item->appendChild($description);
// date
$date = static::element('pubDate', date(DATE_RSS, $post->created));
$item->appendChild($date);
}
// dump xml tree
return static::$document->saveXML();
}
示例2: has_posts
/**
Theme functions for posts
*/
function has_posts()
{
if (($posts = IoC::resolve('posts')) === false) {
$params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc', 'limit' => Config::get('metadata.posts_per_page', 10), 'offset' => Input::get('offset', 0));
$posts = Posts::list_all($params);
IoC::instance('posts', $posts, true);
$total_posts = Posts::count(array('status' => 'published'));
IoC::instance('total_posts', $total_posts, true);
}
return $posts->length() > 0;
}
示例3: generate
public static function generate()
{
// create a dom xml object
static::$document = new DOMDocument('1.0', 'UTF-8');
// create our rss feed
$rss = static::element('rss', null, array('version' => '2.0'));
static::$document->appendChild($rss);
// create channel
$channel = static::element('channel');
$rss->appendChild($channel);
// title
$title = static::element('title', Config::get('metadata.sitename'));
$channel->appendChild($title);
// link
$link = static::element('link', 'http://' . $_SERVER['HTTP_HOST']);
$channel->appendChild($link);
// description
$description = static::element('description', Config::get('metadata.description'));
$channel->appendChild($description);
// articles
$params = array('status' => 'published', 'sortby' => 'id', 'sortmode' => 'desc');
foreach (Posts::list_all($params) as $post) {
$item = static::element('item');
$channel->appendChild($item);
// title
$title = static::element('title', $post->title);
$item->appendChild($title);
// link
$url = 'http://' . $_SERVER['HTTP_HOST'] . Url::make(IoC::resolve('posts_page')->slug . '/' . $post->slug);
$link = static::element('link', $url);
$item->appendChild($link);
// description
$description = static::element('description', $post->description);
$item->appendChild($description);
// date
$date = static::element('pubDate', date(DATE_RSS, $post->created));
$item->appendChild($date);
}
// dump xml tree
return static::$document->saveXML();
}
示例4: index
public function index()
{
$data['posts'] = Posts::list_all(array('sortby' => 'id', 'sortmode' => 'desc'));
Template::render('posts/index', $data);
}