Anu Bhuvanendran Nair Anu Bhuvanendran Nair - 4 months ago 48
Javascript Question

TYPO3 Fluid usage in dynamically rendered template

I'm cooking an extension using EXTbase and fluid for TYPO3 v7+ .
I'm here.. because I'm rendering my fluid templates based on certain controller conditions.Under a condition I want something like the html code being rendered from a user supplied template file.

I've used jQuery to bypass the situation..

<script>
$(function(){
$("#some_div_id").load("template_file.html");
});
</script>


Guess what.. I got the result I expected,but not really..

<div class="clearfix">
<ul id="image-gallery" class="gallery list-unstyled cS-hidden">
<f:for each="{slider}" as="user" key="label" iteration="iterator">
<li data-thumb="{user.src}">
<f:image crop="{user.crop}" treatidasreference="true" src="{user.filepath}" alt="{user.title}" style="width:100%; height:auto;"></f:image>
<f:if condition="{config.metadata.switch}!= 0">
<f:if condition="{user.title}">
<p class="light-caption" style="background: {config.metadata.opacity}; color: {config.metadata.color}; font-size: {config.metadata.size}%; text-align:{config.metadata.align};">{user.title}</p>
</f:if>
</f:if>
</li>
</f:for>
</ul>
</div>


This above is the code resulted.. See, the TypoScript variables are untouched.Little embarrassing.!!

Searching round the clock for an answer.Any ideas ?

Answer

In your controller action you can use $this->view->setTemplate('myDynamicTemplateName'); to use a different template than suggested by the action name.

Refer to: https://typo3.org/api/typo3cms/class_t_y_p_o3_1_1_c_m_s_1_1_fluid_1_1_view_1_1_template_view.html#a9c46c7bfe6a39b26478a2f37aec38d80