如何获得基本URL以及href

时间:2013-08-28 13:21:52

标签: php html html5 magento

目前我在这个地方:

localhost/magento/dresses/adidas-t-shirt.html

我在我的文件中写了这样的

<a href="my/hello/">Click Here</a>

点击Click Here

我变得喜欢

localhost/magento/dresses/my/hello/

但实际上我试着这样做

localhost/magento/my/hello/

我怎样才能得到这个?

5 个答案:

答案 0 :(得分:1)

你也可以按照magento标准尝试下面的

<?php
$_getBase = Mage::app()->getStore()->getBaseUrl();
?>
<a href="<?php echo $_getBase; ?>my/hello/">Link</a>

答案 1 :(得分:0)

您的链接应该是:

<a href="/my/hello/">

或者如果你在phtml文件中,你可能想要使用Magento的原生函数:

<?php echo Mage::getBaseUrl('...'); ?>

答案 2 :(得分:0)

获取网址的正确方法是:

$url = Mage::getUrl('my/hello');

这会给你一个这样的网址:magento_root/my/hello/。如果你想在最后没有斜线的情况下使用

$url = Mage::getUrl('', array('_direct'=>'my/hello'));

答案 3 :(得分:0)

您是否为应用程序设置了基本URL?如果没有,那么设置一个基本URL,你可以这样做,

<a href="<?php echo base_url(); ?>my/hello/">Click Here</a>

我不确定你是否在向Megento询问,如果你是这样看的话。这可能会有所帮助,

http://www.magentocommerce.com/boards/viewthread/8812/

答案 4 :(得分:0)

我相信你正在寻找

echo $this->getUrl("my/hello");