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?

1
  • Hello @Dsingh is it helpful to you?
    – Moin Malek
    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

1
  • Yes, @moin-malek this is helpful for me.
    – D Singh
    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"}}

1
  • 1
    It is not working, i have added this in the block : <p>{{config path="free-catalogue/general/month"}}</p>
    – D Singh
    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'}}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.