[TYPO3-english] Re: Layouts for partials or any other way to avoid copy-paste in templates

Viktor Livakivskyi invisible.kinder at gmail.com
Fri Aug 14 12:18:42 CEST 2015


Hi, Bernd.

Thank you for your answer.

> 3. you can call each section within a partial individually
Yes, and no =) I can call only section of this or other partial from within a partial. But I can't call a section of a template from a partial. Or I just didn't find, how I can do this.

>    < f:render partial="inputfields.html" section="input" 
> arguments="{fieldname:'surname',label:'Surname',required:1,errtxt:'enter 
> your surname',data:user.surname}" />
And that's what I'm, trying  to avoid, because with every new individualization there will be more and more parameters or possible values of parameters, like "isStaticInfoZone: 1, staticInfoCountrySelectorId: 'siCountry', preSelected: 'DE', etc..."

Currently I'm doing it almost as you proposed:
RegistrationForm.html
<f:render partial="Field" section="Main" arguments="{field: 'city', type: 'Textfield'}" />
<f:render partial="Field" section="Main" arguments="{field: 'staticInfoCountry', type: 'SelectCountry', selected: '{user.staticInfoCountry}'}" />

Field.html
<f:section name="Main">
---all the common stuff comes here---
<f:render section="{type}" arguments="{field: '{field}', values: '{values}', selected: '{selected}'}" />
</f:section>

<f:section name="Textfield">
	<f:form.textfield property="{field}" class="form__field form__field_input" id="field-{field}" />
</f:section>

<f:section name="SelectCountry">
	<f:if condition="{selected}">
		<f:then>
			<register:form.SelectStaticCountries property="{field}" id="sfrCountry" value="{selected}" optionLabelField="cnShortEn" class="form__field form__field_select" />
		</f:then>
		<f:else>
			<register:form.SelectStaticCountries property="{field}" id="sfrCountry" value="DE" optionLabelField="cnShortEn" class="form__field form__field_select" />
		</f:else>
	</f:if>
</f:section>

...

So, for each field I either create a special section in partial or add some parameter. But I still don't like this solution, because it forces me to hold specific form adjustments not inside the form template itself, but in partial (or other partials).
In other words: if I want to reuse same partial for other forms with same field layout but their specific adjustments, I'll have to either invent more parameters to pass to Field partial or create more sections. And these specific parameters or sections will be used only once.


More information about the TYPO3-english mailing list