如何使所有的链接与http或https在静态块取决于url


How to make all links with http or https in static block depending on url

我在静态块中使用了标签。

所以如果我使用http://www.example.com

我的href属性链接应该是http://www.example.com/page1

如果我使用https://www.example.com

我的href属性链接应该是https://www.example.com/page1

有没有办法在magento中做到这一点。

谢谢

在静态块中使用不安全的url获取http://www.example.com:

{{config path='web/unsecure/base_url'}}

和安全url获取https://www.example.com在你的静态块:

{{config path='web/secure/base_url'}}

如果你想在静态块中插入条件逻辑,你必须调用静态块中的模板文件并将逻辑放入其中。用途:

<block type="core/template" name="block.name" template="path/to/template.phtml"/>

检查当前url是否安全:

if (Mage::app()->getStore()->isCurrentlySecure()) {
    // Your code logic
}

在php中获取不安全的基础url:

Mage::getBaseUrl();

在php中获取安全的基础url:

Mage::getUrl('',array('_secure'=>true));