I have eight static block list. Client want to change some part of string in these static block according the current month. I can achieve this though the code, but client have access only of backend, so is there any way to change the content in all static block from the single place without editing the code?
-
Hello @Dsingh is it helpful to you?Moin Malek– Moin Malek2017年12月15日 13:17:30 +00:00Commented Dec 15, 2017 at 13:17
3 Answers 3
Please find Below answer help to you.
Goto System->Custom Variables then Create New Variable like this https://prnt.sc/hnv598 then Goto CMS Block write {{customVar code=Test}} or insert variables.
Thanks
-
Yes, @moin-malek this is helpful for me.D Singh– D Singh2017年12月15日 14:44:14 +00:00Commented Dec 15, 2017 at 14:44
As I understand your question, your client want to add dynamic date somewhere in static block. It is not possible out of the box, you should create some kind of reusable widget which your client might use to achieve his goals and which will wrap your logic in reusable element.
Edit: It is not mentioned in description but in the title that you want to get system config value in block; if that is really the case then you can do:
{{config path="system/config/path"}}
For example: {{config path="general/store_information/country_id"}}
-
1It is not working, i have added this in the block : <p>{{config path="free-catalogue/general/month"}}</p>D Singh– D Singh2017年12月15日 09:15:48 +00:00Commented Dec 15, 2017 at 9:15
Yes it's possible to use store configuration value in static block
app/code/VendoreName/ModuleName/etc
di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Variable\Model\Config\Structure\AvailableVariables">
<arguments>
<argument name="configPaths" xsi:type="array">
<item name="sectionName/groupName" xsi:type="array">
<item name="sectionName/groupName/fieldName" xsi:type="string">AddDefaultValue</item>
</item>
</argument>
</arguments>
</type>
</config>
Now you can use this value in any static block in admin
{{config path='sectionName/groupName/fieldName'}}
Explore related questions
See similar questions with these tags.