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


PHP Posts::retrieveById方法代码示例

本文整理汇总了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);
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:41,代码来源:Controller.php

示例2: begin

 public function begin()
 {
     $post_id = $this->getParams('post_id');
     if ($post_id) {
         $this->post = \Posts::retrieveById($post_id);
     }
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:7,代码来源:ArticleBlock.php

示例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();
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:16,代码来源:Post.php

示例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());
 }
开发者ID:hosivan90,项目名称:toxotes,代码行数:16,代码来源:Post.php


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