カスタムモジュールトラブルでCMSとカテゴリの使用のカスタムレイアウトを追加する

magento.stackexchange https://magento.stackexchange.com/questions/1140

質問

私の店には、標準のMagentoレイアウトとまったく異なるレイアウトが必要なカテゴリがあります。そこで、1column.phtmlの新しいコピーを作成し、名前を変更して、テストするために1つの小さな変更を加えました。

問題は、カスタムレイアウトが表示されていないことです。モジュールを作成しました(Admin> Config> Advanced Overviewで見られるように機能しています)。

私のファイルとコンテンツは次のとおりです。

app/etc/modules/test_page.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <active>true</active>
            <codePool>community</codePool>
            <version>0.1.0</version>
            <depends>
                <Mage_Page />
            </depends>
        </Test_Page>
    </modules>
</config>

app/code/local/test/page/etc/config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <version>0.1.0</version>
        </Test_Page>
    </modules>
    <global>
        <page>
            <layouts>
                <homepage module="page" translate="label">
                    <label>Homepage</label>
                    <template>page/home.phtml</template>
                    <layout_handle>homepage</layout_handle>
                </homepage>

                <!-- add more layouts here -->
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <Test_Page>
                    <file>test_page.xml</file>
                </Test_Page>
            </updates>
        </layout>
    </frontend>
</config>

App/Design/FrontEnd/test/default/layout/test_page.xml

    <?xml version="1.0"?> 
<layout>
    <homepage translate="label">
        <label>Home Page</label>
        <reference name="root">
            <action method="setTemplate"><template>page/home.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </homepage> 
</layout>

私が台無しにしたものは何も見えません、それはモジュールとして読まれていますが、カスタムレイアウトは表示されていません:(

役に立ちましたか?

解決

レイアウトドロップダウンに表示するには、カスタムモジュールを作成する必要があります(コアファイルに何かを追加することもできますが、それをしないでください)。拡張機能easylife_layoutに名前を付けましょう。このためには、次のファイルを作成する必要があります。app/etc/modules/Easylife_Layout.xml - 宣言ファイル

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Layout>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Page />
            </depends>
        </Easylife_Layout>
    </modules>
</config>

app/code/local/Easylife/Layout/etc/config.xml - 構成ファイル

<?xml version="1.0"?> 
<config>
    <modules>
        <Easylife_Layout>
            <version>0.0.1</version>
        </Easylife_Layout>
    </modules>
    <global>
        <page>
            <layouts> 
                <lookbook module="page" translate="label">
                    <label>Lookbook</label>
                    <template>page/1column-lookbook.phtml</template>
                    <layout_handle>lookbook</layout_handle>
                </lookbook> 
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <easylife_layout>
                    <file>easylife_layout.xml</file>
                </easylife_layout>
            </updates>
        </layout>
    </frontend>
</config>

app/design/frontend/{interface}/{theme}/layout/easylife_layout.xml - レイアウトファイル

<?xml version="1.0"?> 
<layout>
    <lookbook translate="label">
        <label>Lookbook</label>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </lookbook> 
</layout>

最後のものは、レイアウトファイルでカスタムレイアウトを参照できるようにするために必要です。何かのようなもの:

<update hande="lookbook" />

キャッシュをクリアして...それだけです。それがあなたのために働くかどうかを知っています。

他のヒント

2つの可能性があります:

  1. カスタムレイアウトをカテゴリに追加して、これを行います。

    <layout>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
        </reference>
    </layout>
    
  2. ページレイアウトとして実装し、 config.xmlglobal/page/layouts/ しかし、私はそれを正確に行う方法を知りません。

一度だけ必要な場合は、最初のソリューションにとどまることができます。しかし、注意してください。がある <action method="setIsHandle"><applied>1</applied></action> の中に page.xml この設定により、テンプレートの変更が防止される場合があります。

最初のソリューションを行うには:カテゴリを選択して、 Custom Design そして、すべてを中に入れます <layout /> にノード Custom Layout Update Textarea、例:

<reference name="root">
    <action method="setBackgroundGraphic">
        <background>two-pieces</background>
    </action>
    <action method="setTemplate">
    <template>page/2columns-right-highStep.phtml</template>
    </action>
    <action method="setIsHandle">
        <applied>1</applied>
    </action>
</reference>
ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top