在phtml中的Magento广告变量

时间:2015-04-08 07:07:17

标签: magento magento-1.7

我们的某个联盟会员有一个文件,想要在phtml文件中调用静态块。

必须在这里:

$domain = "domain.com";

domain.com必须是一个变量,我认为最好给它一个静态块,这样我就可以将自己的变量放在那里。它适用于多种商店,因此每个商店视图都需要拥有它自己的变量。

如果有人知道该怎么做,请告诉我。

1 个答案:

答案 0 :(得分:0)

如果所需的域是当前商店URL

使用当前网址的域名

$domain = Mage::getBaseUrl();

如果所需域与当前商店URL

不同

我会将此部分作为系统配置。

创建新模块

app/code/local/Vendor/Module/etc/config.xml

<config>
    <modules>
        <Juno_ProductRegion>
            <version>0.1.0</version>
        </Juno_ProductRegion>
    </modules>
    <global>
        <helpers>
            <vendor_module>
                <class>Vendor_Module_Helper</class>
            </vendor_module>
        </helpers>
    </global>
</config>

app/code/local/Vendor/Module/etc/system.xml

<config>
    <tabs>
        <vendor translate="label" module="module">
            <label>Vendor</label>
        </vendor>
    </tabs>
    <sections>
        <vendor translate="label" module="module">
            <label>Module</label>
            <tab>vendor</tab>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>
            <groups>
                <general translate="label">
                    <label>General</label>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <fields>
                        <affiliate_url translate="label">
                            <label>Affiliate URL</label>
                            <show_in_default>1</show_in_default>
                            <show_in_website>1</show_in_website>
                            <show_in_store>1</show_in_store>
                        </affiliate_url>
                    </fields>
                </general>
            </groups>
        </vendor>
    </sections>
</config>

app/code/local/Vendor/Module/etc/adminhtml.xml

<config>
    <acl>
        <admin>
            <children>
                <system>
                    <children>
                        <config>
                            <children>
                                <vendor>
                                    <title>Vendor</title>
                                </vendor>
                            </children>
                        </config>
                    </children>
                </system>
            </children>
        </admin>
    </acl>
</config>

这会在系统中创建一个标签和部分 - &gt;配置,您可以在其中输入每个商店的会员网址。

要获取联盟网址,您可以使用

<?php echo Mage::getStoreConfig('vendor/general/affiliate_url'); ?>