<?php
 namespace Website\Widgets\Blog; use Moto; use Website; use Zend\Db\Sql\Where; class PostTagsWidget extends Website\Widgets\Blog\AbstractPostsWidget { protected $_name = 'blog.post_tags'; protected static $_defaultProperties = array( 'title' => 'Tags:', 'titleTextStyle' => 'moto-text_normal', 'preset' => 'default', 'spacing' => array( 'top' => 'auto', 'right' => 'auto', 'bottom' => 'auto', 'left' => 'auto', ), ); protected $_tags; public function getTemplatePath($preset = null) { return '@websiteWidgets/blog/templates/post_tags.twig.html'; } public function getTags($page = null) { if ($this->isPreviewMode()) { return [ ['name' => 'Tag 1'], ['name' => 'Tag 2'], ['name' => 'Tag 3'], ['name' => 'Tag 4'], ['name' => 'Tag 5'], ['name' => 'Tag 6'], ['name' => 'Tag 7'], ]; } if ($this->_tags) { return $this->_tags; } $this->_tags = []; if (!$page) { $page = $this->getCurrentPage(); } if (is_callable([$page, 'loadRelation'])) { $page->loadRelation([ 'tags' => function($query) { $query->orderBy('name'); }, ]); $this->_tags = $page->tags; } return $this->_tags; } } 