Magento – How to Get Base URL in system.xml File

base-urlsystem.xml

In the below <comment>
<a href='admin/shipper_method'> tag,
It's not redirecting to the correct page..

<allowedmethods translate="label">
   <label>Allowed Methods</label>
   <frontend_type>multiselect</frontend_type>
   <sort_order>30</sort_order>
   <source_model>ultimate_shipper/resource_method_collection</source_model>
   <show_in_default>1</show_in_default>
   <show_in_website>1</show_in_website>
   <show_in_store>0</show_in_store>
   <can_be_empty>1</can_be_empty>
   <comment><![CDATA[<a href='admin/shipper_method'>Add Custom Method</a>. Example Comment.]]></comment>
</allowedmethods>

What I need is like this,

<a href='http://192.168.1.193/madison/admin/shipper_method'>Add Custom Method</a>

or

<a href='http://example.com/admin/shipper_method'>Add Custom Method</a>

In front-end…

For that, What can I put in the system.xml?

For example:
<comment><![CDATA[<a href='{{baseURL}}admin/shipper_method'>Add Custom Method</a>. Example Comment.]]></comment>

From: https://stackoverflow.com/questions/7686457/how-to-set-link-is-magegetbaseurl-for-breadcrumbs-in-layout/14576428#14576428

Best Answer

You can use a a model to generate the comment for a config field:
Something like this:

<comment>
    <model>ultimate_shipper/adminhtml_allowedmethods_comment</model>
</comment>

then you need to create the file: Ultimate/Shipper/Model/Adminhtml/Allowedmethods/Comment.php with this content:

<?php
class Ultimate_Shipper_Model_Adminhtml_Allowedmethods_Comment
{
    public function getCommentText()
    {
        $text = Mage::helper('ultimate_shipper')->__('Add Custom Method');
        return '<a href="'.Mage::helper('adminhtml')->getUrl('adminhtml/shipper_method').'">'.$text.'</a>';
    }
}
Related Topic