本文整理汇总了PHP中post::getTags方法的典型用法代码示例。如果您正苦于以下问题:PHP post::getTags方法的具体用法?PHP post::getTags怎么用?PHP post::getTags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类post
的用法示例。
在下文中一共展示了post::getTags方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($id = NULL, $page = 1)
{
if (is_null($id) or is_numeric($id)) {
$this->redirect($this->conf['blog_siteurl']);
}
$tag = $id;
$post = new post();
$link = new link();
$comment = new comment();
$this->html->useTheme($this->conf['blog_current_theme']);
$info = array();
$info["isAdmin"] = false;
if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
$info["isAdmin"] = true;
}
$this->themes->info = $info;
$includes['charset'] = $this->html->charsetTag("UTF-8");
$includes['rssFeed'] = $this->html->includeRSS();
if ($page > 1) {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
} else {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
}
$this->registry->includes = $includes;
$this->plugin->call('index_includes');
$includes = null;
foreach ($this->registry->includes as $include) {
$includes .= $include;
}
$this->themes->includes = $includes;
$this->themes->links = $link->findAll();
$this->themes->single = false;
$total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
$page = (int) is_null($page) ? 1 : $page;
$limit = $this->conf['blog_posts_per_page'];
$offset = ($page - 1) * $limit;
$limitQuery = $offset . "," . $limit;
$targetpage = $this->path . "tag/{$tag}/";
$this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
$posts = $post->getPostsByTag($tag, $limitQuery);
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($p['title']);
$posts[$k]['tags'] = $post->getTags($p['ID']);
$posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
$user = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $user->find(1);
} else {
$posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
}
}
$this->registry->posts = $posts;
$this->plugin->call("index_post_content");
$this->themes->posts = $this->registry->posts;
$this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
$this->render();
}
示例2: rss
public function rss($id = NULL)
{
$this->plugin->call('feed_header');
$post = new post();
$this->view->conf = $this->conf;
$this->view->setLayout("feed");
$posts = $post->findAll("ID,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", "ID DESC", $this->conf['blog_posts_per_page'], "WHERE status = 'publish'");
$temp = array();
foreach ($posts as $a_post) {
$temp[$a_post['ID']] = $a_post;
$temp[$a_post['ID']]['tags'] = $post->getTags($a_post['ID'], 'string');
}
$this->view->posts = $temp;
$this->render("rss");
}
示例3: edit
public function edit($id = NULL)
{
$id = (int) $id;
if (!$id) {
$this->redirect('admin');
}
$statuses = array("publish", "draft");
if ($this->data) {
if (isset($this->data['cancelar'])) {
$this->redirect("admin/");
} else {
$P = new post();
$P->find($id);
if (!preg_match("/\\S+/", $this->data['title']) or $this->data['title'] == "") {
$this->data['title'] = "Untitled";
}
if (!preg_match("/\\S+/", $this->data['urlfriendly']) or $this->data['urlfriendly'] == "") {
$this->data['urlfriendly'] = $this->data['title'];
}
$this->data['urlfriendly'] = $P->buildUrl($this->data['urlfriendly'], $id);
$P->updateTags($id, $this->data['tags']);
unset($this->data['tags']);
$P->prepareFromArray($this->data);
$P->save();
$this->session->flash('Información guardada correctamente.');
$this->redirect("admin/edit/{$id}");
}
}
$P = new post();
$post = $P->find($id);
$post['title'] = utils::convert2HTML($P['title']);
$post['content'] = utils::convert2HTML($P['content']);
$post['tags'] = $P->getTags($id, 'string');
$this->title_for_layout($this->l10n->__("Editar post - Codice CMS"));
$this->view->id = $id;
$this->view->post = $post;
$this->view->statuses = $statuses;
$this->view->setLayout("admin");
$this->render();
}