dongpo4197 2013-12-01 16:22
浏览 22
已采纳

magento在同一页面中显示2个不同名称空间的不同模块

I have created two differents modules Test and First associated to different namespaces : Pfay (Test), Train (First).

For some reason this link http://localhost/magento/index.php/first/index/ will call the function IndexAction of Test/controllers/indexController.php as well

Here are the codes : for Test

<?php
 class Pfay_Test_IndexController extends Mage_Core_Controller_Front_Action
{
 public function indexAction()
 {
      $this->loadLayout();
      $this->renderLayout();
 }
}
?>

for First:

    <?php
    class Train_First_IndexController extends Mage_Core_Controller_Front_Action
    {
         public function indexAction()
         {
              $this->loadLayout();
              $this->renderLayout();
              // echo "First Index";
         }
    }

    ?>

config.xml (test)

<?xml version="1.0"?>
  <config>
     <modules>
        <Pfay_Test>
          <version>1.0.0</version>
        </Pfay_Test>
     </modules>
     <frontend>
       <routers>
          <routeurfrontend>
              <use>standard</use>
              <args>
                 <module>Pfay_Test</module>
                 <frontName>test</frontName>
              </args>
           </routeurfrontend>
       </routers>
       <layout>
               <updates>
                    <test>
                         <file>test.xml</file>
                     </test>
                </updates>
        </layout>
    </frontend>
    <global>
     <blocks>
         <test>
              <class>Pfay_Test_Block</class>
         </test>
      </blocks>
    </global>
</config>

config.xml (first)

<?xml version="1.0"?>
  <config>
     <modules>
        <Train_First>
          <version>1.0.0</version>
        </Train_First>
     </modules>
     <frontend>
       <routers>
          <routeurfrontend>
              <use>standard</use>
              <args>
                 <module>Train_First</module>
                 <frontName>first</frontName>
              </args>
           </routeurfrontend>
       </routers>
       <layout>
           <updates>
                <first>
                     <file>first.xml</file>
                 </first>
            </updates>
        </layout>
    </frontend>
    <global>
     <blocks>
         <first>
              <class>Train_First_Block</class>
         </first>
      </blocks>
    </global>
</config>

test.xml

<layout version="0.1.0">
     <default>
          <reference name="content">
          </reference>
      </default>
      <routeurfrontend_index_index>
           <reference name="content">
                <block type="test/monblock"  name="afficher_monbloc"
                          template="test/afficher.phtml" />
           </reference>
      </routeurfrontend_index_index>
      <routeurfrontend_index_mamethode>
           <reference name="content">
                <block type="test/monblock"  name="afficher_monbloc"
                          template="test/afficher2.phtml" />
           </reference>
      </routeurfrontend_index_mamethode>
</layout>

first.xml

<layout version="0.1.0">
     <default>
          <reference name="content">
          </reference>
      </default>
      <routeurfrontend_index_index>
           <reference name="content">
                <block type="first/firstblock"  name="firstblocindex"
                          template="first/first_afficher.phtml" />
           </reference>
      </routeurfrontend_index_index>
      <routeurfrontend_index_mamethode>
           <reference name="content">
                <block type="first/firstblock"  name="firstblocmamethode"
                          template="first/first_afficher.phtml" />
           </reference>
      </routeurfrontend_index_mamethode>
</layout>

And for some reason http://localhost/magento/index.php/test/index/ does not work anymore (404 not found). There are probably some conflicts but I can't find where.

You can see here the problems.

enter image description here

  • 写回答

1条回答 默认 最新

  • dtxooq1020 2013-12-01 17:24
    关注

    In your config file you have created a router alias,

    <routeurfrontend>
    

    which is common for both the plugins, you will need to rename one of them, and correspondingly make changes in the appropriate layout xml. This should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置
  • ¥15 Matlab怎么求解含参的二重积分?
  • ¥15 苹果手机突然连不上wifi了?
  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用