Page\Model\Page::findCachedBySlug PHP Méthode

findCachedBySlug() public static méthode

public static findCachedBySlug ( $slug )
    public static function findCachedBySlug($slug)
    {
        $query = "slug = '{$slug}'";
        $key = HOST_HASH . md5("Page::findFirst({$query})");
        $page = self::findFirst([$query, 'cache' => ['key' => $key, 'lifetime' => 60]]);
        return $page;
    }

Usage Example

 public function contactsAction()
 {
     $page = Page::findCachedBySlug('contacts');
     if (!$page) {
         throw new Exception("Page 'contacts' not found");
     }
     $this->helper->title()->append($page->getMeta_title());
     $this->helper->meta()->set('description', $page->getMeta_description());
     $this->helper->meta()->set('keywords', $page->getMeta_keywords());
     $this->view->page = $page;
     $this->helper->menu->setActive('contacts');
 }
All Usage Examples Of Page\Model\Page::findCachedBySlug