0

I'm updating a Magento plugin and I'd like to add an external link like this:

<a href="myweblink" target "_blank">My weblink </a>

I tried to do it adding these lines in layout.xml file (that is the model I use)

 <?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<referenceContainer name="footer">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="footer_blog_link" before="-">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Condizioni di contratto e termini di utilizzo</argument>
            <argument name="path" xsi:type="string">https://www.fattura24.com/termini-utilizzo/</argument>
            <argument name="target" xsi:type="string">_blank</argument>
        </arguments>
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Regolamento integrarivo (delle Condizioni di Contratto) per l'UTENTE che utilizza moduli per E-Commerce di Fattura24</argument>
            <argument name="path" xsi:type="string">https://www.fattura24.com/regolamento-ecommerce/</argument>
            <argument name="target" xsi:type="string">_blank</argument>
        </arguments>
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Privacy</argument>
            <argument name="path" xsi:type="string">https://www.fattura24.com/policy/</argument>
            <argument name="target" xsi:type="string">_blank</argument>
        </arguments>
    </block>
</referenceContainer>  

I'm not displaying the links in admin footer of my extension.

I put this file in /adminhtml/layout then I updated the app, flushed magento cache, reindexed but still can't display links

  • Why system.xml ? you could not add this in system.xml and the error confirm that. Do it instead in layout – PЯINCƏ Mar 26 at 16:26
0

If you want to add that in admin area:

app/code/Vendor/Modulename/view/adminhtml/layout/your_layout_name.xml

<referenceContainer name="footer">
    <block class="Magento\Framework\View\Element\Html\Link\Current" name="footer_blog_link" before="-">
        <arguments>
            <argument name="label" xsi:type="string" translate="true">Condizioni di contratto e termini di utilizzo</argument>
            <argument name="path" xsi:type="string">https://www.fattura24.com/termini-utilizzo/</argument>
            <argument name="target" xsi:type="string">_blank</argument>
        </arguments>
        ...
  • I added the code you suggested, then I updated my app and flush magento cache, and reindex, but I can't display the link in admin – Davide Iandoli Mar 27 at 8:16
  • The footer of admin Magento or if your admin footer extension ? – PЯINCƏ Mar 27 at 8:58
  • the admin footer of my extension – Davide Iandoli Mar 27 at 9:10
  • ok, can you share me the layout extension content ? – PЯINCƏ Mar 27 at 9:12
  • updated question :-) Thanks – Davide Iandoli Mar 27 at 9:24
0

At last I solved in this way: I edited system.xml adding code like this:

<field id="info_link" translate="label" type="button" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                         <frontend_model>Fattura24\AppFatturazione\Block\System\Config\InfoLink</frontend_model>
</field> 

Then I created an InfoLink.php file:

<?php
namespace Fattura24\AppFatturazione\Block\System\Config;

class InfoLink extends \Magento\Config\Block\System\Config\Form\Field
{
    protected $_template = 'Fattura24_AppFatturazione::system/config/infoLink.phtml';

    public function __construct
    (
        \Magento\Backend\Block\Template\Context $context,
        \Magento\Framework\ObjectManagerInterface $objectManager,
        array $data = []
    )
    {
        $this->objectManager = $objectManager;
        $this->storeManager = $context->getStoreManager();
        parent::__construct($context, $data);
    }

    /**
     * Remove scope label
     *
     * @param  AbstractElement $element
     * @return string
     */
    public function render(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
        return parent::render($element);
    }

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

Eventually I added the template named infoLink.phtml:

<?php echo "<a href=\"https://www.fattura24.com/termini-utilizzo/\" target=\"_blank\">Condizioni di contratto e termini di utilizzo di Fattura24</a>" . "<br />";
      echo "<a href=\"https://www.fattura24.com/regolamento-ecommerce/\" target=\"_blank\">Regolamento F24 integrativo (delle Condizioni di Contratto) per modulo Magento </a>" . "<br />";
      echo "<a href=\"https://www.fattura24.com/policy/\" target=\"_blank\">Privacy di Fattura24</a>" . "<br />";
?>

That is working.

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.