Magento News

 

How to change the URL identifier of a custom module from backend i.e. system configuration

I want to give admin the option to change the URL identifier of MyCustomModule from backend.

E.g.: www.mydomain.com/identifier

What I did is the following:

In etc/system.xml

<identifier translate="label">
    <label>SELF URL Identifier</label>
    <frontend_type>text</frontend_type>
    <sort_order>1</sort_order>
    <show_in_default>1</show_in_default>
    <show_in_website>1</show_in_website>
    <show_in_store>1</show_in_store>
    <comment>(eg: domain.com/identifier)</comment>
</identifier>

In helper/data.php

public function getUrl($identifier = null)
{

    if (is_null($identifier)) {
        $url = Mage::getUrl('').self::getListIdentifier();
    } else {
        $url = Mage::getUrl(self::getListIdentifier()).$identifier;
    }
    return $url;
}

NOTE: I had been told to make some changes in Controller/Router.php but I don’t know what changes to make.

If you want I can add that code also?

Now, what else should I do?

How to change the URL identifier of a custom module from backend i.e. system configuration

Possibly Related Posts:


 

Leave a Reply