2016-07-18 4 views
0

私は最初の部分を作成してレンダリングしようとします。最初に "TableRow.html"というファイルを作成しました。部分がレンダリングされていません

TableRow.html

それから私は、テスト目的のために別名マップを作成しました。全体コード:

<f:layout name="Default" /> 

This Template is responsible for creating a table of domain objects. 

If you modify this template, do not forget to change the overwrite settings 
in /Configuration/ExtensionBuilder/settings.yaml: 
    Resources: 
    Private: 
     Templates: 
     List.html: keep 

Otherwise your changes will be overwritten the next time you save the extension in the extension builder 

<f:section name="main"> 


    <table class="tx_troubleshooterv3" > 
     <tr><td>Test</td></tr> 
     <f:alias 
      map="{ 
       masterpagez: 
       { 
        0: { 
         infotext: 'This is the main page.', 
         questions: 
         { 
          0: { 
           question: 'Main Question A1', 
           pages: 
           { 
            infotext: 'Answer A1', 
            questions: 
            { 
             0: { 
              question: 'Question B1' 
              pages: { 
               infotext: 'Answer B1', 
               questions: 
               { 
                0: { 
                 question: 'Question C1', 
                 pages: { 
                  infotext: 'Answer C1', 
                  questions: NULL 
                 } 
                } 
               } 
              } 
             } 
             1: { 
              question: 'Question B2' 
              pages: { 
               infotext: 'Answer B2', 
               questions: NULL 
              } 
             } 
            } 
           } 
          }, 
          1: { 
           question: 'Main Question A2', 
           pages: 
           { 
            infotext: 'Answer A2', 
            questions: 
            { 
             0: { 
              question: 'Question B2', 
              pages: { 
               infotext: 'Answer B2', 
               questions: NULL 
              } 
             } 
            } 
           } 
          } 
         } 
        } 
       } 
      }" 
     > 


      <f:for each="{masterpagez}" as="masterpage"> 
       <f:for each='{masterpage.questions}' as="qquestion"> 
        <f:for each='{qquestion.pages}' as='page'> 

         <f:render partial="TableRow" arguments="{page: page}"/> 
        </f:for> 
       </f:for> 
      </f:for> 
     </f:alias> 

ご覧のとおり、最初の2つの質問のページを私の部分ファイルに渡してみます。

​​

TableRow.html

しかし、私は出力のみ「テスト」と他には何を得る:その後、私はちょうど私の部分では、これらのページの情報テキストをレンダリングしてみてください。 なぜ私の部分はレンダリングされませんか?

予想される出力:(HTMLなど)

回答A1

回答B2

出力:

Result


更新: 変数 "page"をデバッグしましたが、期待したように2つではなく4つのデバッグボックスが表示されましたか?誰かがこれを説明できますか?

Debug

答えて

1

すべてが期待通りに働いています。あなたの部分はレンダリングされます。しかし、反復アプローチには合わない複雑な配列を作成しています。最後のループ

<f:for each='{qquestion.pages}' as='page'> 

この配列

pages: { 
    infotext: 'Answer B1', 
    questions: 
    { 
     0: { 
      question: 'Question C1', 
      pages: { 
       infotext: 'Answer C1', 
       questions: NULL 
      } 
     } 
    } 
} 

を反復だから最初{page}Answer B1になり、第二には、質問の配列になります。これは正確にあなたが持っているデバッグ出力です。しかしいずれもプロパティーがありませんinfotext、したがって{page.infotext}は何も出力しません。あなたの部分に

<f:for each="{masterpagez}" as="masterpage"> 
    <f:for each="{masterpage.questions}" as="qquestion"> 
     <f:render partial="TableRow" arguments="{infotext: qquestion.pages.infotext}" /> 
    </f:for> 
</f:for> 

そして:あなたの代わりに繰り返しのために、このブロックを試してみて、出力を参照してください

<tr><td><strong>{infotext}</strong></td></tr> 
関連する問題