Reputation: 20342
I try to create and render my first partial. First i created the file "TableRow.html".
Then i created an alias map for testing purposes. Whole code:
<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>
As you can see, i just try to pass the page from the first two questions to my partial file. Then i just try to render the infotext of these pages in my partial:
TableRow.html
<tr><td><strong>{page.infotext}</strong></td></tr>
But i only get the output "test" and nothing else. Why is my partial not rendered?
Expected Output:
Answer A1
Answer B2
Output (as html):
Update:
I just debugged the variable "page" but there are 4 debug boxes displayed instead of 2 like i expected?! Can someone explain this?
Upvotes: 0
Views: 266
Reputation: 7016
Everything is working as expected. Your partial is rendered. But you are creating a rather complex array that does not fit to your iteration approaches. Your last loop
<f:for each='{qquestion.pages}' as='page'>
will e.g. iterate over this array
pages: {
infotext: 'Answer B1',
questions:
{
0: {
question: 'Question C1',
pages: {
infotext: 'Answer C1',
questions: NULL
}
}
}
}
So the first {page}
will be Answer B1
and the second will be the questions array. This is exactly the debug output you got. But neither has a property infotext
, so {page.infotext}
will not output anything. Try this block for your iteration instead and see the output:
<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>
And in your partial:
<tr><td><strong>{infotext}</strong></td></tr>
Upvotes: 1