本文整理汇总了PHP中Posts::retrieveById方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::retrieveById方法的具体用法?PHP Posts::retrieveById怎么用?PHP Posts::retrieveById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Posts
的用法示例。
在下文中一共展示了Posts::retrieveById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUrl
/**
* shortcut call \Flywheel\Router\WebRouter::createUrl() method
* @see \Flywheel\Router\WebRouter::createUrl()
* @param $route
* @param array $params
* @param bool $absolute
* @param string $ampersand
* @return mixed
*/
public function createUrl($route, $params = array(), $ampersand = '&', $absolute = false)
{
$route = trim($route, '/');
if ('post/detail' == $route) {
if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
$params['slug'] = $post->getSlug();
}
} else {
if ('category/default' == $route) {
if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
$params['slug'] = $term->getSlug();
}
} else {
if ('events/default' == $route) {
if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
$params['slug'] = $term->getSlug();
}
} else {
if ('events/detail' == $route) {
if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
$params['slug'] = $post->getSlug();
}
}
}
}
}
$params = Plugin::applyFilters('custom_router_param', $route, $params);
if ($this->currentLang && sizeof($this->languages) > 1) {
$params['lang'] = $this->currentLang->getLangCode();
}
return parent::createUrl($route, $params, $ampersand, $absolute);
}
示例2: begin
public function begin()
{
$post_id = $this->getParams('post_id');
if ($post_id) {
$this->post = \Posts::retrieveById($post_id);
}
}
示例3: executeDetail
public function executeDetail()
{
if (!($post = \Posts::retrieveById($this->request()->get('id')))) {
$this->raise404();
}
$post->setHits($post->getHits() + 1);
$post->save(false);
$term = \Terms::retrieveById($post->getTermId());
if (($viewProp = $term->getProperty('post_view')) && $this->view()->checkViewFileExist($this->getTemplatePath() . '/Controller/Post/' . $this->_path . $viewProp->getPropertyValue())) {
$this->setView('Post/' . $viewProp->getPropertyValue());
} else {
$this->setView('Post/default');
}
$this->view()->assign(array('post' => $post, 'term' => $term));
return $this->renderComponent();
}
示例4: executePin
public function executePin()
{
$this->validAjaxRequest();
$res = new \AjaxResponse();
if (!($post = \Posts::retrieveById($this->request()->get('id')))) {
$res->type = \AjaxResponse::ERROR;
$res->message = t('Post not found!');
return $this->renderText($res->toString());
}
$post->setIsPin(true);
$post->save(false);
$res->type = \AjaxResponse::SUCCESS;
$res->id = $post->getId();
$res->post = $post->toArray();
return $this->renderText($res->toString());
}