質問

アクションボタンに追加の呼び出しを追加するためのモジュールを作成しています。 出力を表示することはできません。私は命名規則やファイルの場所(またはその両方)が間違っていると思います。

ブロックを挿入しようとしている方法であるかもしれません。私がそれを避けることができれば私はphtmlファイルを変更したくないです。

あなたが私のファイルからわかるように、私は を出力するためのいくつかの方法を試しています - 運されないでください。

目的は、カートに追加した後に追加のCTAボタンを追加することができます - 「リクエストサンプル」

ファイル構造:

app
    Code
        local
            CompanyName
                CtaAttributes
                    Block -> CtaButtons.php
                    etc -> config.xml
    design
        frontend
            base
                default
                    layout->ctabuttons.xml
                    template
                        ctaattributes
                            catelog
                               product ->ctabuttons.phtml
.

config.xml

<config>

    ... includes Module and Resource

    <global>
      <blocks>
        <ctaattributes>
            <class>CompanyName_CtaAttributes_Block</class>
        </ctaattributes>
      </blocks>
    </global>

</config>
.

ctabuttons.xml

<?xml version="1.0"?>

<layout version="0.1.0">
    <catalog_product_view>    
        <reference name="content">

                <block type="core/text_list" name="product.info.addtocart" before="addtocart" template="ctaattributes/catalog/product/ctabuttons.phtml"/>
                <action method="append">
                        <block>ctabuttons</block>
                </action>
        </reference>

        <reference name="product.info.addtocart">
            <block type="core/text_list" name="core-text"><action method="setText"><text><![CDATA[<div>Test</div>]]></text></action></block>
        </reference>
    </catalog_product_view>    
</layout>
.

ctabuttons.phtml

<?php
/**
*/
Mage::log(get_class($this));
echo 'this is my test';
.

ctabuttons.php

<?php

class CompanyName_CtaAttributes_Block_CtaButtons extends Mage_Core_Block_Template  {
    echo 'test';

}
.

役に立ちましたか?

解決 4

私は解を見つけました - それは2つの部分にあります。

  1. 私はLayoutの更新のフロントエンド - >更新パスを定義しませんでした。</global>

    の後にこれを挿入しました
      <frontend>
        <layout>
            <updates>
                <ctaattributes>
                    <file>ctaattributes.xml</file>
                </ctaattributes>
            </updates>
        </layout>  
    </frontend>
    
  2. local.xmlを使っていました、私はこれが必要だったと信じていませんが、私のテストでは私はそれを別々に保つためにファイル名を変更するだろうと思いました。

    1. ブロッククラス名
    2. でキャメルケースを使用することはできません。

      原本My ClassはCompanyName_CtaAttributes_Block_CtaButtons - CtaButtons.phpという対応するファイルがありました。
      名前をCompanyName_CtaAttributes_Block_CtabuttonsCtabuttons.phpに変更すると問題が解決されました。

      ブロック/ blockname.phpのクラスファイルまたは問題があるレイアウトXMLファイルであるかどうかわかりません。

      impactのない会社名とモジュールのCamelCaseでテストしました、ブロック名クラスとファイルに制限されているようです。

他のヒント

  • ファイル構造の/blocks/ctabuttons.xmlファイル構造はPHPである必要があります ファイル。
  • / app / etc / modules
  • にする必要があるモジュールファイルが表示されません
  • config.xml
  • にモジュールのバージョン管理が必要です。

最新のパッチを使用する場合は、システム - >権限 - >ブロック

でも許可する必要があります。

こんにちはあなたはブロックタイプを定義する必要がある

から

<?xml version="1.0"?>

 <layout version="0.1.0">
     <catalog_product_view>    
         <reference name="content">

                 <block type="core/text_list" name="product.info.addtocart" before="addtocart" template="ctaattributes/catalog/product/ctabuttons.phtml"/>
                 <action method="append">
                         <block>ctabuttons</block>
                 </action>
         </reference>

         <reference name="product.info.addtocart">
             <block type="core/text_list" name="core-text"><action method="setText"><text><![CDATA[<div>Test</div>]]></text></action></block>
         </reference>
     </catalog_product_view>    
 </layout>
.

<?xml version="1.0"?>

<layout version="0.1.0">
    <catalog_product_view>    
        <reference name="product.info">
            <block type="core/text_list" name="product.info.ctaattributes" before="addtocart" template="ctaattributes/catalog/product/ctabuttons.phtml"/>
        </reference>
    </catalog_product_view>    
</layout>
.

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top