2

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?

asked Dec 15, 2017 at 8:36
1
  • Hello @Dsingh is it helpful to you? Commented Dec 15, 2017 at 13:17

3 Answers 3

2

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

answered Dec 15, 2017 at 12:45
1
  • Yes, @moin-malek this is helpful for me. Commented Dec 15, 2017 at 14:44
1

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"}}

answered Dec 15, 2017 at 8:42
1
  • 1
    It is not working, i have added this in the block : <p>{{config path="free-catalogue/general/month"}}</p> Commented Dec 15, 2017 at 9:15
0

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'}}
answered Jul 21, 2023 at 8:22

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.