1

I am using TYPO3 8 and fluid_styled_content.

In am developing an extension with the following requirements: If specific conditions are met (depending on URL query parameter) nothing should be displayed for the plugin in the Frontend. In this case, the fluid output of the plugin will be empty (depending on a variable that is set in the Controller). But TYPO3 still - by default - renders a wrapping div and the header.

So, essentially, what I get is something like:

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

How do I (dynamically) prevent that?


This has been asked before, but the solutions I found will not work with fluid_styled_content:

Sybille Peters
  • 2,832
  • 1
  • 27
  • 49

2 Answers2

4

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>    
Sybille Peters
  • 2,832
  • 1
  • 27
  • 49
Bernd Wilke πφ
  • 10,390
  • 1
  • 19
  • 38
  • You implemented an override only for your plugin. why not enhance FSC in full? (see my edit above) ok: you need to build a condition in your override which is evaluated every time, but copying all FSC for your plugin is not much easier. – Bernd Wilke πφ Jan 08 '18 at 13:10
  • 1
    Since TYPO3 V8 its lib.contentElement instead of lib.fluidContent. – Tobias Gaertner Aug 01 '19 at 13:56
1

My solution

I managed to find a working solution: However it seems overly complicated :(

What I did was override the List.html fluid Template for my plugins.


My solution in detail

TypoScript: Add fluid_styled_content partial paths to my view, Override the List Template for my plugins:

plugin.tx_myext.view.partialRootPaths < lib.contentElement.partialRootPaths
plugin.tx_myext.view.partialRootPaths.100 = EXT:myext/Resources/Private/Partials/


tt_content.list.templateRootPaths.50 = EXT:myext/Resources/Private/Templates/Override/
  

tt_content.list.templateName = TEXT
tt_content.list.templateName.stdWrap {
    cObject = TEXT
    cObject {
        data = list_type
        override.field = list_type
        if.isInList.field = list_type
        if.value = myext_plugin1,myext_plugin2
        split {
            token = myext_
            1.current = 1
            1.wrap = |
        }
    }
    ifEmpty = List
}

EXT:myext/Resources/Private/Templates/Override/Plugin1.html: Overrides the default List Template, copy-paste of List.html without Layout.

<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:cObject typoscriptObjectPath="tt_content.list.20.{data.list_type}" data="{data}" table="tt_content" />
</html>

EXT:myext/Resources/Private/Templates/MyController/View.html: Use Override/Default Layout

<f:layout name="Override/Default" />
<f:section name="Main" />

EXT:myext/Resources/Private/Layout/Override/Default.html: Is a copy of fluid_styled_content Default layout with hidden functionality.

....
<f:if condition="{hidden}">
    <f:then>

    </f:then>
    <f:else>
 ....

Controller/MyController.php: Must add tt_content data (because header, header_layout, uid etc. are required)

$data = $this->configurationManager->getContentObject()->data;
$this->view->assign('data', $data);
Sybille Peters
  • 2,832
  • 1
  • 27
  • 49