Product specification
The CMS Block Rules Extension allows shop admin to set customer group specific CMS blocks and make them active for a specific time period. When adding a new CMS block or editing an existing CMS block, shop admin can select customer group from the multi-select list and it will be shown only for those specific groups in frontend. Shop admin can also choose a 'Active From' and 'Active To' date for CMS blocks to display in frontend for a specific period.
Features
- Create CMS blocks based on customer group.
- Set a CMS block to be activated for a specific time period using ‘Active From’
and ‘Active To’ date fields. - CMS blocks can be saved as disabled for future ‘Active From’ date in backend
and will be enabled automatically on that date. - All existing CMS blocks will be available for all customer groups initially, unless
specific selection is done.
Pre-requisites
Magento 2.3.x or 2.4.x.
Installation
To install the module, follow the steps below.
- Download the module/extension and unzip it.
- Access your web server directories and upload the content of the folder into app/code/Pits/CMSRule/ directory.
- Run the following commands to complete the installation.
- Enable the module - php bin/magento module:enable
- Update of the database - php bin/magento setup:upgrade
- Generate and pre-compile classes - php bin/magento setup:di:compile
- Deploy static files - php bin/magento setup:static-content:deploy
Screenshots / Video
Initially the block will be working as Magento default functionality because the block is not assigned to any particular customer group.
When adding new CMS block or editing an existing CMS block, select the customer group for whom the CMS block should display in the front end.
If we select ‘ALL GROUPS’ from the list and save the block it will select the all the customer groups for you.
There is an option to select ‘Active From’ and ‘Active To’ date from which the block should be active. If the ‘Active From’ date is greater than current date, it will not get active. Also, the block automatically gets active when the ‘Active From’ date is reached and the block automatically gets disabled when ‘Active To’ date is reached. The module sets a cron job for that.
Need to set the default magento cron for the shop which uses the module.
The CMS Blocks grid view will show the ‘customer group’ and ‘Active From’ and ‘Active To’ date.
Customer can select ‘Active from’ and ‘Active To’ date. If the ‘Active From’ date is later than current date, then it will not be possible to save the block. If you want to save this block you need to disable the block and save it.
The block will be enabled automatically when the ‘Active from’ date becomes current date.
Adding blocks to pages
for adding to a CMS page go to CONTENT > Elements > Pages. Select the page that you want to add the block to from Acton column Select > Edit.
Select ‘Edit with page Builder’ from ‘Content’.
Drag and drop ‘Block’ from ‘Add Content’ section from the left side.
Select the gear icon for editing.
Click the ‘Select Block’ button to add a block from the list.
Select the block using ‘Select’ button.
After selecting and setting the display settings from ‘Advanced’ section click on ‘Save’ button.
After closing the page builder, the block will show in the content section.
After all changes to page, we can save the page using ‘Save’ button.
We can also add CMS blocks in other cms blocks and pages using:
We can add CMS block in phtml and xml layout file also,
In phtml:
<?php
echo $this->getLayout()
->createBlock('Magento\Cms\Block\Block')
->setBlockId('your_block_identifier')
->toHtml();
?>
<referenceContainer name="content">
<block class="Magentoo\Cms\Block\Block" name="block_identifier">
<arguments>
<argument name="block_id" xsi:type="string">block_identifier</argument>
</arguments>
</block>
</referenceContainer>
After the changes has been made, flush the cache in the backed and load it in frontend to see the changes.
Technical Requirements / Compatible with:
Magento Community 2.3.X and 2.4.X
Supported Languages
English, German.
Change Log / Release Notes
Version: 1.0.1:
Compatible with Open Source (CE): 2.4.6
Version: 1.0.0:
Initial release.
Compatible with Open Source (CE): 2.3 and 2.4
Support
If you have questions use our contact form in webshopextension.com.