2016-07-18 5 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> 

위에서 볼 수 있듯이 처음 두 질문의 페이지를 부분 파일로 전달하려고합니다.

TableRow.html

<tr><td><strong>{page.infotext}</strong></td></tr> 

을하지만 난 단지 출력 "테스트"와 아무것도 얻을 : 그럼 난 그냥 내 부분에서이 페이지의 텍스트를 렌더링하려고합니다. 왜 내 부분이 렌더링되지 않습니까?

예상 출력 :

응답 A1

응답 B2

출력 (HTML 등) :

Result


업데이트 : 방금 ​​"페이지"변수를 디버깅했지만 예상했던 것처럼 2 대신 2 개의 디버그 상자가 표시 되었습니까?! 누군가 이것을 설명 할 수 있습니까? 예상대로

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>