小编kha*_*ato的帖子

如何从后端即系统配置更改自定义模块的URL标识符

我想给admin提供更改MyCustomModule后端URL标识符的选项.

例如:www.mydomain.com/identifier

我做的是以下内容:

etc/system.xml中

<identifier translate="label">
    <label>SELF URL Identifier</label>
    <frontend_type>text</frontend_type>
**<backend_model>press/config_identifier</backend_model>** // edited after answer
    <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>
Run Code Online (Sandbox Code Playgroud)

helper/data.php中

public function getUrl($identifier = null)
{

    if (is_null($identifier)) {
        $url = Mage::getUrl('').self::getListIdentifier();
    } else {
        //$url = Mage::getUrl(self::getListIdentifier()).$identifier;
**$url = Mage::getUrl(self::getListIdentifier(), array('identifier' => $identifier,'_use_rewrites'=>true)); //edited
        }**
    return $url;
}
Run Code Online (Sandbox Code Playgroud)

之后我创建了一个模型文件identifier.php:

class FME_Press_Model_Config_Identifier extends Mage_Core_Model_Config_Data

{

    protected function _afterSave()

    {

        if ($this->isValueChanged()) {

            $path = $this->getValue();



            // for each $store and $id combination...



            Mage::getModel('core/url_rewrite') …
Run Code Online (Sandbox Code Playgroud)

magento magento-1.4 magento-1.5

3
推荐指数
1
解决办法
2556
查看次数

标签 统计

magento ×1

magento-1.4 ×1

magento-1.5 ×1