Magento 2- Create System Configuration file and get value of config field in .phtml file

Magento 2: Create System Configuration file and get value of config action in .phtml file- 

Step 1: Create menu.xml file-

Path– app\code\Vendor\Modulename\etc\adminhtml\


<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../Magento/Config/etc/system_file.xsd">
<system>
<tab id="sample_demo" translate="label" sortOrder="10">
<label>Tab Label</label>
</tab>
<section id="section_id" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Tab Label 1</label>
<tab>sample_demo</tab>
<resource>Vendor_Modulename::vendor_modulename</resource>
<group id="group_id" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0"
showInStore="0">
<label>General</label>
<field id="field_id" translate="label comment" type="select" sortOrder="10" showInDefault="1"
showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment>
This option will enable or disable the functionality of this module.
</comment>
</field>
</group>
</section>
</system>
</config>

 

Step 2: Get value of field in .phtml file-


$config_value = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('section_id/group_id/field_id');