2014-01-14 188 views
1

我只是想为我的magento网站创建一个单独的模块。我只是按照与here提到的相同的步骤。但我得到404错误。你好世界在magento不工作

我不知道它为什么发生。我在管理面板中有我的默认存储视图。是因为它不工作的原因吗?

这是我目前运行的打印网址“你好指数”

http://my_domain.ca/web/frontier/helloworld

如果可以请帮我家伙。我在这里问stackoverflow,因为那个博客是3岁,我不会很快得到答复。

config.xml中

<config>  
    <modules> 
     <Alanstormdotcom_Helloworld> 
      <version>0.1.0</version> 
     </Alanstormdotcom_Helloworld> 
    </modules> 
</config> 

<config>  
    <frontend> 
     <routers> 
      <helloworld> 
       <use>standard</use> 
       <args> 
        <module>Alanstormdotcom_Helloworld</module> 
        <frontName>helloworld</frontName> 
       </args> 
      </helloworld> 
     </routers> 
    </frontend> 
</config> 

和Alanstormdotcom_Helloworld.xml

<config> 
    <modules> 
     <Alanstormdotcom_Helloworld> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Alanstormdotcom_Helloworld> 
    </modules> 
</config> 
+0

你是否清除你的magento配置缓存目录(normaly var/cache)。 – Seb

+0

@seb请告诉我如何清除缓存我已经清除了系统/缓存管理缓存 – user3110655

+0

删除那里的所有文件/目录。 – Seb

回答

1

您已经使用<的.config在config.xml文件两次>,它会导致错误。你的配置文件应该是这样的。

<config>  
<modules> 
    <Alanstormdotcom_Helloworld> 
     <version>0.1.0</version> 
    </Alanstormdotcom_Helloworld> 
</modules> 
<frontend> 
    <routers> 
     <helloworld> 
      <use>standard</use> 
      <args> 
       <module>Alanstormdotcom_Helloworld</module> 
       <frontName>helloworld</frontName> 
      </args> 
     </helloworld> 
    </routers> 
</frontend> 
</config> 

此文件应位于app/code/local/Alanstormdotcom/Helloworld/etc/config.xml位置。

您还需要添加控制器文件。它应该增加在位置应用程序/代码/本地/ Alanstormdotcom /的Helloworld /控制器/ IndexController.php

<?php 

class Myproject_Helloworld_IndexController extends Mage_Core_Controller_Front_Action 
{ 
    public function indexAction() 
    { 
     echo 'Hello world!'; 
    } 
} 

注意每个文件夹的名称。第一个字母应该是大写字母。在控制器文件中,您可以看到,我没有使用?>符号。这是因为这是我们在magento文件中使用的协议。

现在清除缓存。并尝试加载该页面。页面url应该是

yourdomain.com/index.php/hellworld 
+0

哇谢谢人,它的工作。 – user3110655