2011-01-07 27 views
5

Magentoのログインフォームとアカウントフォームを1つのページにまとめようとしています。理由は、私はちょうど少ないページが良いと思います。私はMagentoが混乱し、レイアウトとテンプレートシステムの理解が限られていることがわかりました。これを行う最も簡単な方法は、登録帳ページにログインフォームを追加することだと決めました。 login.phtmlとregister.phtmlのログインフォームと登録フォームがテンプレート/ customer/form /に見つかりました。Magentoのログインと登録フォームの1ページ

login.phtmlのPHTMLコードを同じディレクトリにあるregister.phtmlファイルに単純にコピーしました。 、私は、アカウントのメールアドレスとパスワードを記入し、ログインをクリックした後

http://pastebin.com/fpkeBsxc

それ怒鳴るレジスタアカウントフォームを参照する検証エラーのページに戻ります:これは私がしてしまったものです。基本的には、私のアプローチが完全に愚か/間違っていて、このようなコードをコピーして貼り付けることができないか、これは私が見ることができない単純なhtmlの問題なのかどうかはわかりません。私はレジスタフォームが機能するので、間違った方法かもしれないと思う。このスクリーンショットをコメントに投稿します。複数のリンクを貼り付けることはできません。アドバイスありがとう。

+0

http://img137.imageshack.us/img137/2458/49833894.png – HeinekenBluess

答えて

2

あなたはそれをわずかに異なる操作を行う必要があります。

  1. は、Magentoのレイアウトを知ってもらうと、それは1つのテンプレート
  2. 彼らのに提出しましょうとの両方の既存のフォームを含めること
  3. 使用レイアウトの参照がどのように機能しますか既存のコントローラ
+0

が同意しているつもり: は今、顧客のログインページをキャッシュをクリアして再ロードします。残念ながら、いくつかのphtmlファイルを組み合わせるのは簡単ではありません。 – Nic

7

テーマ内のcustomer.xmlでは、アカウントの登録ブロックをログインページ内に移動できます。 uはuが顧客に配置したいですHTMLを置くことができ、このことにより

<customer_account_login translate="label"> 
    <label>Customer Account Login Form</label> 
    <!-- Mage_Customer --> 
    <remove name="right"/> 
    <remove name="left"/> 

    <reference name="root"> 
     <action method="setTemplate"><template>page/1column.phtml</template></action> 
    </reference> 
    <reference name="content"> 
     <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"/> 


    <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml"> 
      <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" translate="label"> 
       <label>Form Fields Before</label> 
      </block> 
     </block> </reference> 
</customer_account_login> 
+0

これは私をたくさん助けました、ありがとう! – djdy

6
<reference name="content">    
    <block type="customer/form_login" name="customer_form_login" template="customer/form/login.phtml"> 
     <block type="customer/form_register" name="customer_form_register" template="customer/form/register.phtml" />    
    </block> 
</reference> 

/フォームのデフォルトのログインフォームで顧客登録フォームをマージするために/ login.phtml

<?php echo $this->getChildHtml('customer_form_register') ?> 
2


1. mini.register.phtmlファイルを作成する
まず、新しいテンプレートファイルを作成する必要があります。app/design/frontend/[your-interface]/[your-theme]/template/customer/form/mini.register.phtml
デフォルトレジスタファイルの内容:app/design/frontend/base/default/template/customer/form/register.phtmlをmini.register.phtmlにコピーし、要件に合わせてカスタマイズします。 app/design/frontend/base/default/template/customer/form/login.phtmlあなたの現在のテーマに:login.phtml
最初のコピーでファイルmini.register.phtml含める

2.

app/design/frontend/[your-interface]/[your-theme]/template/customer/form/login.phtml 

そして今、あなたは新しいログインを変更する必要があります。 phtmlのように、mini.register.phtmlの内容を含めることができます。今、あなたは単にあなたの新しいログインにmini.register.phtmlを含めることができ

<customer_account_login translate="label"> 
    <reference name="content"> 
     <action method="unsetChild"><child>customer_form_login</child></action> 
     <block type="customer/form_login" name="customer_form_login2" template="customer/form/login.phtml" > 
      <block type="customer/form_register" name="customer_form_register2" template="customer/form/mini.register.phtml"> 
       <block type="page/html_wrapper" name="customer.form.register.fields.before" as="form_fields_before" /> 
      </block> 
     </block> 
    </reference> 
    <reference name="head"> 
     <action method="setTitle" translate="title" module="customer"><title>Login or Create an Account</title></action> 
    </reference> 
</customer_account_login> 

:このため
は、あなたが通り(好ましくはapp/design/frontend/[your-interface]/[your-theme]/layout/local.xmlで)あなたのレイアウトxmlファイルに次のXMLコードを使用する必要があります。PHTMLファイルとして:あなたが終わっ

<?php echo $this->getChildHtml('customer_form_register2'); ?> 
  1. http://your-mage-store/customer/account/login
+0

あなたの答えを投稿してくれてありがとう! [自己プロモーションに関するよくある質問](http://stackoverflow.com/faq#promotion)をよく読んでください。また、自分のサイト/製品にリンクするたびに免責条項を掲示することが必須*であることにも注意してください。 –

関連する問題