1

私はマジェントの初心者です。カスタム モジュールを追加し、そのカスタム モジュールのルーティングを行いました。ただし、何も表示されず、空白のページが表示されます!!!! ページが見つからないというメッセージさえありません。ここに私のコードがあります..

私の設定ファイルは次のとおりです app/code/local/Test/Test/etc/config.xml

<config>
<modules>
    <Test_Test>
        <version>0.7.1</version>
    </Test_Test>
</modules>
<frontend>
    <routers>
        <test>
            <use>standard</use>
            <args>
                <module>Test_Test</module>
                <frontName>test</frontName>
            </args>
        </test>
    </routers>
<layout>
    <updates>
        <test>
            <file>test.xml</file>
        </test>
    </updates>
</layout>
</frontend>

app/etc/modules/Test_Test.xml の私の Test_Test.xml ファイル

<config>
    <modules>
        <Test_Test>
            <active>true</active>
            <codePool>local</codePool>
        </Test_Test>
    </modules>
</config>

app/code/local/Test/Test/controllers/IndexAction.php の私の IndexController.php ファイル

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

app/design/frontend/default/default/layout/test.xml の私の test.xml ファイル

<layout version="0.7.0">
    <test_index_index>
        <reference name="root">
            <action method="setTemplate">
                <template>page/1column.phtml</template>
            </action>
        </reference>
        <reference name="content">
            <block type="test/view" name="test_index_view" template="test/view.phtml" />
        </reference>
     </test_index_index>
</layout>

app/design/frontend/default/default/template/test/view.phtml の私の view.phtml ファイル

<?php 
    echo "test test test test";
?>

私は次のURLをurl 1と呼びました:

http://localhost:8888/magento/index.php/test/index/index

URL 2:

http://localhost:8888/magento/index.php/test/index

URL 3:

http://localhost:8888/magento/index.php/test

URL 4:

http://localhost:8888/magento/test

その結果、すべて空白のページが表示されます。「404 not found 1」ページも表示されません。問題を引き起こすのを手伝ってください。前もって感謝します..

4

2 に答える 2

5

複数の問題。

  • etc/config.xmlファイルに終了</config>タグがありません。
  • コントローラー ファイルに名前を付けましIndexAction.phpた。である必要がありますIndexController.php
  • を使用indexActionする必要があります$this->loadLayout()->renderLayout();
  • あなたlayout/test.xmlは undefined block を使用していますtest/view。とりあえず使うpage/html

view.phtmlこれらの問題を修正した後、ネイキッド 1.7.0.2 でのサンプル出力を確認できます。

于 2013-11-05T08:15:24.497 に答える
1

Magento 1.7.0.2 のルーティングで同様の問題が発生していますが、すべてのモジュール ルーティング チェーンは正しいです (さまざまなモジュールでタイプミスや欠落している要素を何度もチェックし、キャッシュをクリアしました (var フォルダーでも))。

そして、何時間もグーグルで検索し、考えられるすべての解決策を試した結果、Magento 1.7.0.2 (1.7 ではない) のカスタム ルーティングに問題があるようです。

特に、最初の 3 つのコード チャンクのパターンを使用します。ただし、それが役立つ場合は、次を試すことができます。

http://www.pierrefay.com/magento-create-controller-36 (特にコメントでの議論)

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch

お役に立てば幸いです。この問題が解決した場合はお知らせください。

于 2013-11-20T13:48:24.807 に答える