Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Block/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ protected function _preparePostCollection()
\Magefan\Blog\Helper\Config::XML_PATH_HOMEPAGE_DISPLAY_MODE,
ScopeInterface::SCOPE_STORE
);

/* If featured posts enabled */
if ($displayMode == 1) {
$postIds = $this->_scopeConfig->getValue(
\Magefan\Blog\Helper\Config::XML_PATH_HOMEPAGE_FEATURED_POST_IDS,
ScopeInterface::SCOPE_STORE
);
$this->_postCollection->addPostsFilter($postIds);
} else {
$this->_postCollection->addRecentFilter();
}
}

Expand Down
11 changes: 11 additions & 0 deletions Block/Sidebar/Recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ public function _construct()
return parent::_construct();
}

/*
* Prepare posts collection
*
* @return void
*/
protected function _preparePostCollection()
{
parent::_preparePostCollection();
$this->_postCollection->addRecentFilter();
}

/**
* Retrieve block identities
* @return array
Expand Down
1 change: 1 addition & 0 deletions Block/Widget/Recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ protected function _preparePostCollection()

parent::_preparePostCollection();

$this->_postCollection->addRecentFilter();
if ($category = $this->getCategory()) {
$this->_postCollection->addCategoryFilter($category);
}
Expand Down
11 changes: 10 additions & 1 deletion Model/ResourceModel/Post/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,16 @@ public function addStoreFilter($store, $withAdmin = true)
}
return $this;
}


/**
* Add "include in recent" filter to collection
* @return $this
*/
public function addRecentFilter()
{
return $this->addFieldToFilter('include_in_recent', 1);
}

/**
* Add posts filter to collection
* @param array|int|string $category
Expand Down
31 changes: 24 additions & 7 deletions Setup/UpgradeSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}

if (version_compare($version, '2.2.0') < 0) {
/* Add author field to posts tabel */
/* Add author field to posts table */
$connection->addColumn(
$setup->getTable('magefan_blog_post'),
'author_id',
Expand All @@ -84,7 +84,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con


if (version_compare($version, '2.2.5') < 0) {
/* Add layout field to posts and category tabels */
/* Add layout field to posts and category table */
foreach (['magefan_blog_post', 'magefan_blog_category'] as $table) {
$table = $setup->getTable($table);
$connection->addColumn(
Expand Down Expand Up @@ -165,7 +165,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}

if (version_compare($version, '2.3.0') < 0) {
/* Add meta title field to posts tabel */
/* Add meta title field to posts table */
$connection->addColumn(
$setup->getTable('magefan_blog_post'),
'meta_title',
Expand All @@ -178,7 +178,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
]
);

/* Add og tags fields to post tabel */
/* Add og tags fields to post table */
foreach (['type', 'img', 'description', 'title'] as $type) {
$connection->addColumn(
$setup->getTable('magefan_blog_post'),
Expand All @@ -193,7 +193,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
);
}

/* Add meta title field to category tabel */
/* Add meta title field to category table */
$connection->addColumn(
$setup->getTable('magefan_blog_category'),
'meta_title',
Expand Down Expand Up @@ -452,7 +452,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}

if (version_compare($version, '2.6.2') < 0) {
/* Add include in menu field into categories tabel */
/* Add include in menu field into categories table */
$connection->addColumn(
$setup->getTable('magefan_blog_category'),
'include_in_menu',
Expand All @@ -473,7 +473,7 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
}

if (version_compare($version, '2.6.3') < 0) {
/* Add display mode field into category tabel */
/* Add display mode field into category table */
$connection->addColumn(
$setup->getTable('magefan_blog_category'),
'display_mode',
Expand All @@ -488,6 +488,23 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con
);
}


if (version_compare($version, '2.6.3.1') < 0) {
/* Add include in recent posts into post table */
$connection->addColumn(
$setup->getTable('magefan_blog_post'),
'include_in_recent',
[
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT,
null,
'nullable' => false,
'default' => '1',
'comment' => 'Include in Recent Posts',
'after' => 'is_active'
]
);
}

$setup->endSetup();
}
}
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magefan_Blog" setup_version="2.6.3">
<module name="Magefan_Blog" setup_version="2.6.3.1">
<sequence>
<module name="Magento_Cms"/>
<module name="Magento_Catalog"/>
Expand Down
18 changes: 18 additions & 0 deletions view/adminhtml/ui_component/blog_post_form.xml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,24 @@
</argument>
</container>
</container>
<field name="include_in_recent">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="dataType" xsi:type="string">boolean</item>
<item name="label" xsi:type="string" translate="true">Include in Recent Posts</item>
<item name="formElement" xsi:type="string">checkbox</item>
<item name="prefer" xsi:type="string">toggle</item>
<item name="source" xsi:type="string">post</item>
<item name="sortOrder" xsi:type="number">60</item>
<item name="dataScope" xsi:type="string">include_in_recent</item>
<item name="valueMap" xsi:type="array">
<item name="true" xsi:type="number">1</item>
<item name="false" xsi:type="number">0</item>
</item>
<item name="default" xsi:type="number">1</item>
</item>
</argument>
</field>
</fieldset>
<!-- Revert htmlContent to enable post gallery images on Magento 2.2.2
<htmlContent name="gallery" sortOrder="22">
Expand Down