I have a module for Homepage Banner. I have stated two system config fields inside the module- etc/adminhtml/system.xml.

enter image description here

I need the values of these fields in frontend phtml file "view/frontend/templates/html/banner.phtml".

How will I get these system config fields('enable' and 'banner_content_type') values?

1 Answer 1


Recommended way

namespace QaisarSatti\HelloWorld\Helper;

class Data extends \Magento\Framework\App\Helper\AbstractHelper
    public function getConfig($config_path)
        return $this->scopeConfig->getValue(

get values in phtml

$helper = $this->helper('QaisarSatti\HelloWorld\Helper\Data');

Not Recommended way

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$conf = $objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('bannertab/settings/banner_content_type');

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.