1

解決済み: 愚かな私は、コンパイルを有効にしていました...オフにすると、期待どおりに動作しました。とにかく、あなたの時間をありがとう:)

気が狂う。これを機能させるために(正しいものを除いて)すべてを試しましたが、標準メニュー以外のコンテンツはレンダリングされません。バックエンドで「こんにちは」をレンダリングする単純なブロックを作成しようとしています。たとえば、mage のブロックを catalog.xml からコピーすると、正常に動作します。

<block type="adminhtml/catalog_product" name="products_list">

ご意見をお聞かせください。

config.xml

<?xml version="1.0"?>

<config>
    <modules>
        <Wish_Scheduleproduct>
            <version>0.0.1</version>
        </Wish_Scheduleproduct>
    </modules>
    <global>
        <models>
            <scheduleproduct>
                <class>Wish_Scheduleproduct_Model</class>
            </scheduleproduct>
        </models>
        <helpers>
            <scheduleproduct>
                <class>Wish_Scheduleproduct_Helper</class>
            </scheduleproduct>
        </helpers>
        <blocks>
            <scheduleproduct>
                <class>Wish_Scheduleproduct_Block</class>
            </scheduleproduct>
        </blocks>
    </global>
    <frontend>
        <routers>
            <scheduleproduct>
                <use>standard</use>
                <args>
                    <module>Wish_Scheduleproduct</module>
                    <frontName>scheduleproduct</frontName>
                </args>
            </scheduleproduct>
        </routers>
        <layout>
            <updates>
                <wish_scheduleproduct>
                    <file>scheduleproduct.xml</file>
                </wish_scheduleproduct>
            </updates>
        </layout>
    </frontend>
    <admin>
        <routers>
            <scheduleproduct>
                <use>admin</use>
                <args>
                    <module>Wish_Scheduleproduct</module>
                    <frontName>scheduleproduct</frontName>
                </args>
            </scheduleproduct>
        </routers>
    </admin>
    <adminhtml>
        <layout>
            <updates>
                <scheduleproduct>
                    <file>scheduleproduct.xml</file>
                </scheduleproduct>
            </updates>
        </layout>
        <menu>
            <scheduleproduct translate="title">
                <title>Schedule product</title>
                <sort_order>40</sort_order>
                <depends>
                    <module>Wish_Scheduleproduct</module>
                </depends>
                <children>
                    <openings translate="title">
                        <title>Handle open hours</title>
                        <action>scheduleproduct/admin_schedule</action>
                        <sort_order>1</sort_order>
                    </openings>
                </children>
            </scheduleproduct>
        </menu>
    </adminhtml>
</config>

scheduleproduct.xml (レイアウトの更新)

<?xml version="1.0"?>

<layout version="0.1.0">
    <scheduleproduct_admin_schedule_index>
        <reference name="menu">
            <action method="setActive"><menupath>scheduleproduct/openings</menupath></action>
        </reference>
        <reference name="content">
            <block type="scheduleproduct/admin_test" name="myTester" />
        </reference>
    </scheduleproduct_admin_schedule_index>
</layout>

ScheduleController.php

class Wish_Scheduleproduct_Admin_ScheduleController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();

    }
}

ブロック

<?php

class Wish_Scheduleproduct_Block_Admin_Test extends Mage_Adminhtml_Block_Template
{
    protected function _construct()
    {
        echo "Hello";;      
    }
}

ファイルツリーはこちら: http://i.stack.imgur.com/N0QLG.png

ご協力ありがとうございました!

メソッド mageFindClassFile から生成されたインクルード パスを確認しましたが、ブロック パスが含まれていないようです。

4

1 に答える 1

1

モジュール構造を再作成し、ブロックがページに正常に追加されました。ここからアーカイブをダウンロードして、自分のバージョンと比較してください。私が見る3つの可能な犯人は

  1. という名前のブロックを追加する別のモジュールがmyTesterある場合、奇妙なことが起こる可能性があります

  2. あなたは自分がどこにいるかについて言及していませんでしscheduleproduct.xmlた。正しい場所にあり、Magento によって処理されていることを確認してください

  3. ブロック ファイルecho "hello"のコンストラクターに が含まれていました。それは機能しますが、ページの上部に「こんにちは」という単語が出力されます。コンテンツ領域には何も追加されません。コンテンツ領域に何かを追加したい場合は_toHtml、文字列を返します。(この例については、リンクされたモジュールを参照してください)

ここに画像の説明を入力

于 2013-02-02T02:31:01.333 に答える