2

モジュール名の参照を作成するだけです。次に、紹介ブロックを別のモジュール テンプレート ファイル名 success.phtml に配置します。それはできますか?

referral.xml (紹介モジュール内)

 <?xml version="1.0"?>
    <layout version="0.1.0">

            <checkout_onepage_success>
<reference name="checkout.success">
                    <block type="referral/referral" name="referralCallLink"><action method="referralCallLink"></action></block>
                </reference>
            </checkout_onepage_success>
            <!--block type="referral/referral" name="referralAddSession"><action method="referralAddSession"></action></block-->

    </layout>

成功.phtml

<?php if($hasBoughtMCash): ?>
<div> Your 
<?php echo implode(', ',$hasBoughtMCash); ?>
 purchase is successful.
</div>
<?php endif; ?>
<h2>Share in Facebook and Earn for Free MCash!</h2>
<?php echo $this->getChildHtml(); ?>

Referral.php(ブロック)

public function referralCallLink() //success page
    {
    ...

    $collection7 = Mage::getModel('referral/referrallink')->getCollection();
    $collection7->addFieldToFilter('customer_id', array('eq' => $cust_id));
    $collection7->addFieldToFilter('grouped', array('eq' => $grouped));

        foreach($collection7 as $data3)
        {
         $product = $data3->getData('product');
         $link = $data3->getData('link');
         $imageurl = $data3->getData('url');            
        //facebook
         $title=urlencode('Shop, Save and Get Rewarded at MRuncit.com');
         $url=urlencode($link);
         $summary=urlencode('I just bought  '.$product.' from MRuncit.com and earned some MReward Points!');
         $image=urlencode($imageurl);

        ?>
        <p>
        <a href="http://www.facebook.com/sharer.php?s=100&amp;p[title]=<?php echo $title;?>&amp;p[summary]=<?php echo $summary;?>&amp;p[url]=<?php echo $url; ?>&amp;p[images][0]=<?php echo $image;?>','sharer','toolbar=0,status=0,width=548,height=325');" target="_blank">
        <img src="<?php echo $imageurl;?>" width="30">
        I just bought  <?php echo $product; ?> from MRuncit.com and earned some MReward Points!
        </a>
        </p>
        <?php

        }
    }

結果 ここに画像の説明を入力

4

1 に答える 1

0

レイアウトXMLで成功ブロックの子としてブロックを作成する必要があります。

<layout_handle_of_the_success_page>
    <reference name="name_of_the_success_block_in_layout">
        <block type="your/referral_block" />
    </reference>
</layout_handle_of_the_success_page>

次に、success.phtmlに次の行を挿入できます。

<?php echo $this->getChildHtml('referral'); ?>

サンプルXMLには、独自の名前に置き換える必要のある名前がいくつかあります。

  • layout_handle_of_the_success_page-対応するモジュールのレイアウトXMLにあります。->checkout_onepage_successの形式である必要がありますmodule_controller_action
  • name_of_the_success_block_in_layoutname-これもレイアウトXMLから、success.phtmlテンプレートとその属性を持つブロックを探します-> checkout.success
  • your/referral_block-これは、フォームに挿入するブロックのクラスエイリアスですmodule/class ->紹介/紹介
于 2013-03-11T13:38:30.727 に答える