TYPO3 - How to display form in grid element? - forms

I use TYPO3 v10.4.8 with the extension gridelements and the core form extension. I have included the form into my created grid element in the backend, but it's not visible in frontend. This is a part of my grid template:
<f:if condition="{children}">
<f:for each="{children}" as="columns" key="rowNumber">
<div class="row grid-row grid-row-{rowNumber}">
<f:if condition="{columns}">
<f:for each="{columns}" as="column" key="columnNumber">
<div class="col-12 grid-column grid-column-{columnNumber}">
<f:for each="{column}" as="child">
<div class="inner">
<f:cObject typoscriptObjectPath="tt_content.{child.data.CType}" data="{child.data}" table="tt_content" />
</div>
</f:for>
</div>
</f:for>
</f:if>
</div>
</f:for>
</f:if>
My configuration:
lib.gridelements.defaultGridSetup =< lib.contentElement
lib.gridelements.defaultGridSetup {
templateName.field = tx_gridelements_backend_layout
templateName.ifEmpty = GridElement
layoutRootPaths {
10 = EXT:gridelements/Resources/Private/Layouts/
20 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
10 = EXT:gridelements/Resources/Private/Partials/
20 = {$page.fluidtemplate.templateRootPath}
}
templateRootPaths {
10 = EXT:gridelements/Resources/Private/Templates/
20 = {$page.fluidtemplate.templateRootPath}
}
dataProcessing {
10 = GridElementsTeam\Gridelements\DataProcessing\GridChildrenProcessor
10 {
default {
as = children
options {
resolveChildFlexFormData = 0
}
}
}
}
}
The Render.html file from the core module is called, but the variable formConfiguration is empty, so no form is rendered.

Since a form element uses the pi_flexform field to select the form definition, you have to disable the automatic FlexForm resolver of Gridelements.
By default Gridelements with dataProcessing is meant to be rendering everything within a FLUID template by accessing variables and settings directly. So the default setting of the DataProcessor is to resolve FlexForm XML data into arrays.
To disable that behaviour you can use the option
resolveFlexFormData = 0
to disable it for a container and its children or
resolveChildFlexFormData = 0
to still resolve container FlexForms but skip those of child elements.

Related

Using the Dataprocessor from TYPO3 8

I try to use the dataprocessor from TYPO3 8 to make my menu.
I have this code in my TypoScript script:
page = PAGE
page{
10 = FLUIDTEMPLATE
10 {
file = fileadmin/abis/templates/BootstrapTmpl.html
partialRootPath = fileadmin/abis/Partials/
layoutRootPath = fileadmin/abis/Layouts/
}
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
entryLevel= 0
excludeUidList = 27,30,31
levels = 5
#includeSpacer = 1
titleField = nav_title // title
as = huhu
}
}
...
}
And this one in a section:
<f:section name="myMenu" >
<f:debug title="title">{huhu}</f:debug>
<f:cObject typoscriptObjectPath="obj.logo" />
<ul class="nav navbar-nav navbar-left">
<f:for each="{huhu}" as="menuItem">
<li>
{menuItem.text}
<f:if condition="menuItem.subItems">
<f:render section="myMenu" arguments="{myMenu: menuItem.subItems}" />
</f:if>
</li>
</f:for>
</ul>
</f:section>
My HTML output is empty. The variable {huhu} is empty. And I don't know why. Does anybody have an idea?
Try to put your dataProcessing into page.10:
page = PAGE
page {
10 = FLUIDTEMPLATE
10 {
file = fileadmin/abis/templates/BootstrapTmpl.html
partialRootPath = fileadmin/abis/Partials/
layoutRootPath = fileadmin/abis/Layouts/
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
entryLevel= 0
excludeUidList = 27,30,31
levels = 5
#includeSpacer = 1
titleField = nav_title // title
as = huhu
}
}
}
}
First, the "dataProcessing" has to be done inside page.10. And second you have to give your arguments over to your section in the "f:render" tag. Don't know if you do that, because that part is missing in your example code.
I had a similar problem and my typoscript code was correct. However, I forgot to add
arguments="{_all}"
when calling
<f:render partial="header" arguments="{_all}" />
in my layout.
You can also use <f:debug>{huhu}</f:debug> in your Partial, if huhu is null you might have forgotten about the arguments="{_all}".

TYPO3 v8.5 with Fluidtemplate and fluid-styled-content - Partials not working

I use TYPO3 v8.5 with fluid-templating (with layout, partials and template) and fluid-styled-content.
However, as soon as I create a fsc-element e.g. text&media on my site, the partial files are ignored and only the section from the template file is output in the FE.
If I set the content-element to "hide", then the correct site-structure with partials were output in the FE.
My root-template is:
page = PAGE
page.includeCSS {
main = fileadmin/Demo/Resources/Public/Css/main.css
}
page.10 = FLUIDTEMPLATE
page.10 {
layoutRootPaths {
10 = fileadmin/Demo/Resources/Private/Layouts
20 = fileadmin/Demo/Individual/Private/Layouts
}
partialRootPaths {
10 = fileadmin/Demo/Resources/Private/Partials
20 = fileadmin/Demo/Individual/Private/Partials
}
templateRootPaths {
10 = fileadmin/Demo/Resources/Private/Templates
20 = fileadmin/Demo/Individual/Private/Templates
}
variables {
contentMain < styles.content.get
}
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = pagelayout
default = TEXT
default.value = fileadmin/Demo/Resources/Private/Templates/DefaultTemplate.html
pagets__1 < .default
}
}
My page-TSconfig:
mod.web_layout.BackendLayouts {
1 {
title = Default Template
config {
backend_layout {
colCount = 1
rowCount = 1
rows {
1 {
columns {
1 {
name = Main Content
colPos = 0
}
}
}
}
}
}
}
}
DefaultLayout.html :
<f:render partial="Header"/>
<f:render section="Main"/>
<f:render partial="Footer"/>
Footer.html :
<div class="footer-container">
<footer class="wrapper">
Hier steht der Footer-Text
</footer>
</div>
Header.html :
<div class="header-container">
<header class="wrapper clearfix">
<h1 class="title">LOGO</h1>
<nav>
Hier erscheint die Navigation
</nav>
</header>
</div>
DefaultTemplate.html :
<f:layout name="DefaultLayout"/>
<f:section name="Main">
<div class="main-container">
<div class="main wrapper clearfix">
<article>
<f:format.raw>{contentMain}</f:format.raw>
</article>
</div>
</div>
</f:section>
Does anyone know this behavior and can give me a tip what's wrong with my code.
In TYPO3 v7.6 this code works fine.
There is currently an open bug (see https://forge.typo3.org/issues/77235) regarding this issue. Try to rename your Partials as a workaround until this is fixed.

How to have Frontend Layout determine columns and backend layout?

Is there a way to have the Frontend layout determine the Backend layout, template file and columns?
At the moment I have the following code that allows you to set the Backend layout and it uses the appropriate template file. But this gets very messy when there are different column positions for each layout.
page.10 = FLUIDTEMPLATE
page.10 {
#format = html
file= fileadmin/templates/example/partials/example_home.html
partialRootPath = fileadmin/templates/example/partials/
layoutRootPath = fileadmin/templates/example/layouts/
variables {
# Assign the Columns
main < styles.content.get
main.select.where = colPos = 0
news < styles.content.get
news.select.where = colPos = 1
}
}
}
# Assign the Template files with the Fluid Backend-Template
page.10.file.stdWrap.cObject = CASE
page.10.file.stdWrap.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
# Set the default Template
default = TEXT
default.value = fileadmin/templates/example/partials/example_home.html
# Set a second Template
23 = TEXT
23.value = fileadmin/templates/example/partials/example_internal.html
}
Not messy at all, here's a real world example:
page.10 = FLUIDTEMPLATE
page.10 {
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = pagelayout
default = TEXT
default.value = {$customPagesTemplatePath}/Standard.html
1 = TEXT
1.value = {$customPagesTemplatePath}/Home.html
2 = TEXT
2.value = {$customPagesTemplatePath}/Landing.html
10 = TEXT
10.value = {$customPagesTemplatePath}/NewsDetail.html
11 = TEXT
11.value = {$customPagesTemplatePath}/LandingMini.html
12 = TEXT
12.value = {$customPagesTemplatePath}/FullWidth.html
}
layoutRootPath = {$customPagesLayoutPath}
partialRootPath = {$customPagesPartialPath}
}
Think about it like this:
As you say, forget about frontend layout. That's legacy; be layout serves for BE and FE.
If a page was a city, the colPos would be the street. Or rather, imagine the Backend is a map you're drawing, and the frontend is a LEGO City you build according tho that map :-)) If it's OK, I'll stick with that metaphor.
ColPos is a determined part of a page where a record lives. If you can, take a look at the tt_content table in the database: you'll see that colPos is just a column with a number. So in the city "Page 1", there's a street called "colPos 7", and it contains some records (those would be houses). With the be_layout wizard in TYPO3 you'll create an administrative map of that city: how the editor should see these streets.
In the FLUIDTEMPLATE you call depending on the selected be_layout, you will create the city itself; the rendered frontend.
Here's another real world example for such a fluid template (Home.html):
<f:render partial="Mobilenav" />
<f:render partial="Header"/>
<div class="row">
<f:cObject typoscriptObjectPath="lib.home-teaser" />
</div>
<aside>
<div class="row">
<div class="columns">
<div class="row">
<div class="fp-teaser-outer small-48 medium-24 large-12 columns">
<div class="fp-teaser-box-wrapper">
<f:cObject typoscriptObjectPath="lib.home-something" />
</div>
</div>
<div class="fp-teaser-outer small-48 medium-24 large-12 columns">
<div class="fp-teaser-box-wrapper">
<f:cObject typoscriptObjectPath="lib.home-somethingelse" />
</div>
</div>
<div class="fp-teaser-outer small-48 medium-24 large-12 columns">
<div class="fp-teaser-box-wrapper">
<div class="fp-teaser-box">
<f:cObject typoscriptObjectPath="lib.home-news-plugin-title" />
<div class="fp-teaser-hr"></div>
<div class="fp-teaser-content">
<f:cObject typoscriptObjectPath="lib.home-news" />
</div>
</div>
</div>
</div>
<div class="fp-teaser-outer small-48 medium-24 large-12 columns">
<div class="fp-teaser-box-wrapper">
<div class="fp-teaser-box">
<f:cObject typoscriptObjectPath="lib.home-blog-plugin-title" />
<div class="fp-teaser-hr"></div>
<div class="fp-teaser-content">
<f:cObject typoscriptObjectPath="lib.home-blog" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</aside>
<f:render partial="Footer"/>
... well, but where's the correlation with the colPos?
Nowhere yet! I (while being positive that there are other approaches) do this in TypoScript:
lib.home-something < styles.content.get
lib.home-something {
select.where = colPos = 7
}
So by this we prepare content for the fluid template: get all content of that page's column 7 (using the extension fluid_styled_content) and put it into a "lib" content object.
That's then inserted into the page via the f:cObject viewhelper:
<f:cObject typoscriptObjectPath="lib.home-something" />
Like this, all houses in 7th street are put into the city in exactly this location – and thus rendered in your page.
Programmatically,
$backendLayout=$GLOBALS['TSFE']->cObj->getData('pageLayout');
If None was selected in the backend [-1], it will output 'none'.
If nothing was selected it will output 'default'. Otherwise it will output the correct backend layout prefixed with your extension, taking into account subpage layouts up the page ancestry chain.

TYPO3 - Custom page types not showing in menu

in my TYPO3 7.5 project I have created some custom page types by registering them in ext_tables.php as described further here
I can select those page types in the backend, no errors, all good. Also checking for a certain page-type via statements in the frontend works fine.
Now I want to create a menu of those (sub-)page trees. The TypoScript solution looks like this and works fine:
lib.tourTeasers = HMENU
lib.tourTeasers {
special = directory
wrap = <section class="row">|</section>
1 = TMENU
1 {
wrap = <div class="col-sm-12">|</div>
expAll = 1
NO {
doNotLinkIt = 1
linkWrap = <h2 style="text-align:right">Kategorie: |</h2>
}
}
2 = TMENU
2{
expAll = 1
NO{
doNotLinkIt = 1
linkWrap = <h3>Tourtyp: |</h3>
}
}
3 = TMENU
3{
NO{
doNotLinkIt = 1
linkWrap = <h4>|</h4>
after.cObject = COA
after.cObject {
stdWrap.dataWrap = <div class="row teaser">|</div>
10 = FILES
10 {
references {
table = pages
fieldName = media
}
renderObj=IMAGE
renderObj{
file{
width=300c
height=150c
#maxW=257c
#maxH=150c
import.data= file:current:publicUrl
}
altText.data = file:current:title
#altText.field=abstract
#titleText.field=nav_title
#stdWrap.dataWrap = |</a>
stdWrap.dataWrap(
<a href="index.php?id={field:uid}" title="Tour {field:title} ansehen">
<div class="col-sm-4 teaser__image">|</div>
</a>
)
params = class="img-responsive"
}
}
30 = TEXT
30.field = abstract // bodytext
30.crop = 250
30.wrap = <div class="col-sm-8 teaser__description"><p>|</p>
40 = TEXT
40.value = Ansehen
40.typolink.parameter.field = uid
40.typolink.ATagParams = class="btn"
40.wrap = <div class="button teaser__cta">|</div></div>
}
}
}
}
My problem is:
If I use the very Fluid Viewhelper that is intended to render exacly the same
<v:page.menu.directory pages="{page_uid}" as="tours" expandAll="true">
<f:for each="{tours}" as="tour">
<div class="row">
<div class="col-sm-3">
<v:page.resources.fal table="pages" field="media" uid="{tour.uid}" as="images">
<f:for each="{images}" as="image">
<f:image src="{image.url}" alt="{image.alternative} {image.name}" title="{image.title}" class="img-responsive"/>
</f:for>
</v:page.resources.fal>
</div>
<div class="col-sm-9">
<h3>{tour.title}</h3>
{tour.abstract}
</div>
</div>
</f:for>
</v:page.menu.directory>
{page_uid} being the parent page, nothing is displayed.
If I change some of the sub-pages' doktype back to "default" they are displayed in the rendered menu.
any idea as to why this is? Am i missing a certain argument in the viewhelper? i also tried to set the allowed doktypes in the viewhelper but that doesn't change anything.
thanks for the reponses, indeed it had to do with the doktype, is I didn't include the "new" ones for both the parent pages AND their sub-pages. Works now, solved. Fluid really rocks

How do I check for column content in a typo3 fluid template?

I have a typo3 fluid template in which I want to check if content exists before rendering some elements.
Is there an efficient way to do this?
eg.
<f:if condition="{contentInColPos0}">
<div class="section-content">
<f:render section="Main" />
</div>
</f:if>
Is there a built-in variable or a simple way to check content exists in a column position?
This is a common task in CMS templating (don't render this part unless there's something to show), but I can't seem to find how to do it simply.
There is no easy way to do that. But you can use some TypoScript and then pass the count to Fluid and use it in a condition:
lib.countContent = CONTENT
lib.countContent {
table = tt_content
select {
selectFields = count(uid) AS count
pidInList = this
andWhere = (deleted = 0 AND hidden = 0)
}
renderObj = COA
renderObj {
10 = TEXT
10 {
data = field:count
}
}
This object will output the number of content rows on the given page and can be accessed in Fluid:
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.countContent')} > 0">
Then show some stuff
</f:if>
If you're going to use the content anyway and don't have global wrap in your content object, you can also use it directly because the Fluid IfViewHelper checks for empty strings. So e.g. this might be working even better:
lib.content < styles.content.get
(This object is empty if there is no content)
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.content')}">
<f:then>
<f:format.html>{lib.content}</f:format.html>
</f:then>
<f:else>
No content found
</f:else>
</f:if>
Easyest way to check this with VHS and without TypoScript:
<f:if condition="{v:content.get(column:6) -> v:iterator.first()}">
<div class="myAmazingClass">
</div>
</f:if>
You can slide the content throug subpages if you want:
<f:if condition="{v:content.get(column:6, slide:'-1') -> v:iterator.first()}">
<div class="myAmazingClass">
</div>
</f:if>
Consider VHS with ViewHelpers https://fluidtypo3.org/viewhelpers/vhs/master/Content/GetViewHelper.html or https://fluidtypo3.org/viewhelpers/vhs/master/Content/RenderViewHelper.html combined with using the as argument and an f:if condition to check the assigned variable for being empty.
You can solve this easily:
In your TypoScript file:
lib.contentInColPos0 < styles.content.get
lib.contentInColPos0 t.select.where = colPos = 0
In your Template file:
<f:if condition="{f:cObject(typoscriptObjectPath:'lib.contentInColPos0')}">
<div class="section-content">
<f:render section="Main" />
</div>
</f:if>