0

How do I show the content of other sites in my system configuration, Please provide me a solution

 <group id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="0"
                   showInStore="0">
                <label>abcd</label>
                <frontend_model>xx\yy\Block\Adminhtml\System\Config\Extensions</frontend_model>
                <comment>  
                <![CDATA[
                <iframe id="mp-core-partners" src="https://www.123.com/core/sbc.html" frameborder="0" scrolling="no" width="100%" height="1700px" style="min-height: 800px;"></iframe>
                ]]>
                </comment>
</group>
1

Remove comment tag if you want to add the same in system config. You have already defined frontend_model so create a block file with specified value in it with following code.

<?php

namespace [Vendor]\[Module]\Block\Adminhtml\Form\Field;

class Customfield extends \Magento\Config\Block\System\Config\Form\Field
{
    /**
     * @param \Magento\Backend\Block\Template\Context $context
     * @param array $data
     */
    public function __construct(
        \Magento\Backend\Block\Template\Context $context,
        array $data = []
        )
    {
        parent::__construct($context, $data);
    }

    /**
     * Set template.
     */
    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('[Vendor]_[Module]::system/form/field/custom.phtml');
    }

    public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        // Remove scope label
        $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
        $configValue = (string) $element->getValue();
        $values = [];
        if (strlen($configValue) > 0) {
            $values = explode(',', $configValue);
        }
        $this->setConfigValue($values);

        return parent::render($element);
    }

    public function getSelectedAttributes()
    {
        $options = [];

        return $options;
    }

    /**
     * Return element html.
     *
     * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
     *
     * @return string
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        return $this->_toHtml();
    }
}

The create a phtml file

[Vendor]/[Module]/view/adminhtml/templates/system/form/field/custom.phtml

With whatever you want to add like

<iframe id="mp-core-partners" src="https://www.123.com/core/sbc.html" frameborder="0" scrolling="no" width="100%" height="1700px" style="min-height: 800px;"></iframe>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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