diff --git a/Block/Widget/Recent.php b/Block/Widget/Recent.php index b3471b29..14b50f14 100755 --- a/Block/Widget/Recent.php +++ b/Block/Widget/Recent.php @@ -1,6 +1,6 @@ getCategory()) { $this->_postCollection->addCategoryFilter($category); } + + if ($tagId = $this->getData('tag_id')) { + $this->_postCollection->addTagFilter($tagId); + } + + if ($authorId = $this->getData('author_id')) { + $this->_postCollection->addAuthorFilter($authorId); + } + + if ($from = $this->getData('from')) { + $this->_postCollection + ->addFieldToFilter('publish_time', array('gteq' => $from . " 00:00:00")); + } + + if ($to = $this->getData('to')) { + $this->_postCollection + ->addFieldToFilter('publish_time', array('lteq' => $to . " 00:00:00")); + } } /** diff --git a/Model/Config/Source/Tag.php b/Model/Config/Source/Tag.php index f839f7cf..f924019f 100755 --- a/Model/Config/Source/Tag.php +++ b/Model/Config/Source/Tag.php @@ -9,7 +9,7 @@ namespace Magefan\Blog\Model\Config\Source; /** - * Used in recent post widget + * Used in recent post widget & post edit page * */ class Tag implements \Magento\Framework\Option\ArrayInterface diff --git a/Model/Config/Source/WidgetTag.php b/Model/Config/Source/WidgetTag.php new file mode 100755 index 00000000..abcb4291 --- /dev/null +++ b/Model/Config/Source/WidgetTag.php @@ -0,0 +1,32 @@ +options === null) { + parent::toOptionArray(); + array_unshift($this->options, ['label' => __('Please select'), 'value' => 0]); + } + + return $this->options; + } + +} diff --git a/etc/widget.xml b/etc/widget.xml index dc3b5144..de92ba05 100755 --- a/etc/widget.xml +++ b/etc/widget.xml @@ -1,7 +1,7 @@