0

我正在使用TYPO3 8fluid_styled_content

在开发具有以下要求的扩展时:如果满足特定条件(取决于 URL 查询参数),则前端中的插件不应显示任何内容。在这种情况下,插件的流体输出将为空(取决于控制器中设置的变量)。但是 TYPO3 仍然 - 默认情况下 - 呈现包装 div 和标题。

所以,基本上,我得到的是这样的:

<div id="c217" class="...">
  <header>
    <h2 class="...">Header</h2>
  </header>
  <p> <!-- plugin output here is empty -- > </p>
</div>

我如何(动态地)防止这种情况发生?


之前有人问过这个问题,但我发现的解决方案不适用于流体样式内容:

4

1 回答 1

3

You should use the FSC way.
All content is rendered with templates which use layouts and partials. Aside from the simple CEs you have a template for plugins which requests a layout which renders the header.

Enhance the (global) layout with a special condition for your plugin to avoid the header (be sure to render the header by yourself) or avoid the header if your plugin will not render any output.


EDIT:

add the override template-pathes to FSC:

lib.contentElement {
   templateRootPaths {
      200 = EXT:your_extension_key/Resources/Private/FSC/Templates/
   }
   partialRootPaths {
      200 = EXT:your_extension_key/Resources/Private/FSC/Partials/
   }
   layoutRootPaths {
      200 = EXT:your_extension_key/Resources/Private/FSC/Layouts/
   }
}

now you can copy the default-layout from the FSC folder to your layout folder and add in that layout a condition which skips the header and global wrapping if your plugin is rendered.

<f:if condition="{data.CType} == 'list' && {data.list_type} == 'myPlugin'">
  <f:then>
    <f:comment> only plugin output </fcomment>

  </f:then>
  <f:else>
    <f:comment> original output with headers and wrap </fcomment>

  </f:else>
</f:if>    
于 2018-01-07T22:03:44.837 回答