1

I have added a custom field- Fax number on System > Configuration > General > Store information. I need to use this variable value in my cms page.
There are system variables which we can use in our cms blocks like {{store_name}}, {{store_email}}.
I want to use my fax number as a variable. Something like {{store_fax_number}}
I have tried creating custom variable but don't know how to add a configuration field value to that variable.
I know I can add directly my fax number to a custom variable. But I don't want to do that. I want to add a field in store information and then use that value in custom variable.
If anyone have any idea please help.

2 Answers 2

4

I found the solution.
To use a custom field value in cms block, you can use the below code.
I added a new field named fax in system.xml file located at local/Mage/Core/etc/ the code for adding the field is,

<config>
......
<general translate="label" module="core">
......
<groups>
......
<store_information translate="label">
......
    <fax translate="label">
       <label>Store Fax Number</label>
       <frontend_type>text</frontend_type>
       <sort_order>22</sort_order>
       <show_in_default>1</show_in_default>
       <show_in_website>1</show_in_website>
       <show_in_store>1</show_in_store>
    </fax>
......
</store_information>
......
</groups>
......
</general>
......
</config>

Now to use this variable value in your cms block you just need to add below code

{{config path="general/store_information/fax"}}

here fax is the name of your field.

1
  • This is still accurate, however if you have security patch SUPEE-6788 (APPSEC-1057) applied you will also need to whitelist the new variables in the Magento Admin under this page: System -> Permissions -> Variables Following the example, you would click the Add new variable button, the Variable name would be general/store_information/fax and you would set the Is Allowed option to Yes.
    – PromInc
    Commented Sep 1, 2017 at 16:25
2

The non-coding approach would be to use the inbuilt Custom Variables. You can find them under System -> Custom Variables. These will appear automatically in the Insert Variables selection screen when editing your CMS pages.

Alternatively if you add your fax number with code FAX you can use the following snippet in your CMS pages, email templates

{{customVar code=FAX}}
1
  • Thanks Fooman for this reply. I know I can add directly my fax number to a custom variable. But I don't want to do that. I want to add a field in store information and then use that value in custom variable.. Have any suggestion?? Commented Oct 22, 2013 at 5:02

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.