TYPO3 - FilesProcessor - print out image tag in FLUID Template - typo3

I want to read out the "images" from a content element with FilesProcessor.
But I can't get the files array filled
In the TYPO3-Backend I add an image to the content element:
My TypoScript:
// Part 1: Fluid template section
page.10 = FLUIDTEMPLATE
page.10 {
templateName = TEXT
templateName {
cObject = TEXT
cObject {
data = pagelayout
required = 1
case = ucfirst
split {
token = pagets__
cObjNum = 1
1.current = 1
}
}
ifEmpty = Default
}
templateRootPaths {
0 = EXT:site_package/Resources/Private/Templates/Page/
1 = {$page.fluidtemplate.templateRootPath}
}
partialRootPaths {
0 = EXT:site_package/Resources/Private/Partials/Page/
1 = {$page.fluidtemplate.partialRootPath}
}
layoutRootPaths {
0 = EXT:site_package/Resources/Private/Layouts/Page/
1 = {$page.fluidtemplate.layoutRootPath}
}
}
page.10 {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\MenuProcessor
10 {
levels = 1
includeSpacer = 1
as = mainnavigation
}
20 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
20 {
table = tt_content
orderBy = sorting
where = colPos = 1
as = jumbotronContent
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
as = images
reference.fieldName = image
}
}
}
}
}
My Jumbotron-Content-Element HTML-Template:
<f:debug title="all" inline="true">{_all}</f:debug>
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<section class="hero">
<div class="d-flex container">
<div class="d-flex flex-column justify-content-center">
<f:for each="{jumbotronContent}" as="Jumbotron" iteration="iter">
<h1>{Jumbotron.data.header}</h1>
<h2>{Jumbotron.data.subheader}</h2>
<button>SABER MAIS AGORA</button>
</f:for>
</div>
<div class="hero-image d-flex justify-content-center">
<f:for each="{images}" as="image">
<f:debug>{image}</f:debug>
<f:image image="{image.originalFile}"/>
</f:for>
</div>
</div>
</section>
</html>
But the f:debug-Viewhelper tells me
images => array(empty)
How can I fill the image array? I probably put the FilesProcessor code on the wrong place.
Can someone plase assist.
Thank you

Your configuration has a typo: it should be references (plural):references.fieldName
page.10.dataProcessing.20.dataProcessing.10.references.fieldName = image

Related

Microdata for news item in breadcrumb navigation

With the following code I build my breadcrumb navigation with the according microdata for a BreadcrumbList:
lib.breadcrumb = COA
lib.breadcrumb {
wrap = <ol class="list-inline" role="menubar" itemscope itemtype="http://schema.org/BreadcrumbList">|</ol>
10 = HMENU
10 {
special = rootline
special.range = 0|-1
1 = TMENU
1 {
wrap = |
NO {
allWrap = <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
stdWrap.htmlSpecialChars = 1
linkWrap = |
doNotLinkIt = 0 |*||*| 1
ATagBeforeWrap = 1
ATagTitle.field = nav_title // title
ATagParams = role="menuitem" itemprop="item"
stdWrap.wrap = <span itemprop="name">|</span>
after.cObject = COA
after.cObject {
5 = TEXT
5.dataWrap = <meta itemprop="position" content="{register:count_MENUOBJ}|" />
}
}
}
}
}
This works perfectliy fine, but I have no idea, how to add the item <meta itemprop="position" content="{register:count_MENUOBJ}|" /> for a newsrecord:
This is how it looks at the moment:
// add news title to breadcrumb if needed
[globalVar = GP:tx_news_pi1|news > 0]
lib.breadcrumb.10.1.NO.doNotLinkIt = 0
lib.breadcrumb.20 = COA
lib.breadcrumb.20 {
wrap = <li class="article" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
after.cObject = COA
after.cObject {
5 = TEXT
5.dataWrap = <meta itemprop="position" content="{register:count_MENUOBJ}|" />
}
10 = RECORDS
10 {
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news.field = title
conf.tx_news_domain_model_news.htmlSpecialChars = 1
wrap = <span itemprop="name">|</span>
}
}
[end]
Obviously the {register:count_MENUOBJ} is not available for the news item.
How can I get the last value of {register:count_MENUOBJ} from the menu object and increase it by one for the news item?
I had the same problem, my solution is to work with the CUR element:
lib.breadcrumb = COA
lib.breadcrumb {
stdWrap.wrap = <ol class="list list--inline" itemscope itemtype="http://schema.org/BreadcrumbList">|</ol>
10 = HMENU
10{
special = rootline
special.range = 0|-1
includeNotInMenu = 1
1 = TMENU
1{
noBlur = 1
expAll = 1
NO = 1
NO.wrapItemAndSub = <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">|</li>
NO.stdWrap.htmlSpecialChars = 1
NO.stdWrap.htmlSpecialChars.preserveEntities = 1
#NO.doNotLinkIt = |*| 0 |*| 1
NO {
ATagParams = itemprop="item"
stdWrap.wrap = <span itemprop="name">|</span>
after = <meta itemprop="position" content="{register:count_MENUOBJ}" />
after.insertData = 1
}
}
}
}
[(request.getQueryParams()['tx_news_pi1'])['news'] > 0]
lib.breadcrumb {
10 {
1 {
CUR < .NO
CUR {
doNotLinkIt = 1
stdWrap2 {
typolink {
# Detail page
ATagParams = itemprop="item"
parameter.field = uid
additionalParams.data = GP:tx_news_pi1|news
# If there is a plugin with mode "Detail", the controller and action parameter might be skipped
additionalParams.wrap = &tx_news_pi1[controller]=News&tx_news_pi1[action]=detail&tx_news_pi1[news]=|
useCacheHash = 1
stdWrap = <span itemprop="name">|</span>
}
}
stdWrap.cObject = RECORDS
stdWrap.cObject {
if.isTrue.data = GP:tx_news_pi1|news
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
}
}
}
}
}
}
[global]

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.

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

Wrapping image url in typo3

I used the typoscript below, only the image is not wrapped in <img src="|" class="tip-image" alt="">, it only generates the image url. Out is shown below. What do I wrong?
tipmenu = HMENU
tipmenu.special = directory
tipmenu.special.value = 8
tipmenu {
1 = TMENU
1 {
expAll = 1
wrap = <div class="left_links">|</div>
NO {
stdWrap.cObject = COA
stdWrap.cObject {
10 = FILES
10 {
references {
data = levelmedia:-1, slide
}
renderObj = COA
renderObj {
10 = IMG_RESOURCE
10 {
file.import.data = file:current:publicUrl
file.maxW = 50
file.maxH = 50
}
}
}
10.wrap = <img src="|" class="tip-image" alt="">
20 = TEXT
20.field = title
20.wrap = <span class="tip-title">|</span>
30 = TEXT
30.field = subtitle
30.wrap = <span class="tip-subtitle">|</span>
}
}
}
}
Hereby the html output:
<div class="left_links">
<a href="tips/verhalen-van-klanten/">
fileadmin/_processed_/csm_klanten_e92ee310e0.png
<span class="tip-title">Verhalen van klanten</span>
<span class="tip-subtitle">Wat vind jij?</span>
</a>
</div>
FILES has no wrap. Use your wrap inside a stdWrap.
10.stdWrap.wrap = <img src="|" class="tip-image" alt="">
Some hints:
Maybe you should add a maxItems = 1 inside Files. If an editor inserts two or more images the output would look like this: <img src="image1.jpgimage2jpgimage3.jpg" class="tip-image" alt="">
You do not need the COA. Use the IMG_RESOURCE directly unless there is a reason for the COA.
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:publicUrl
file.maxW = 50
file.maxH = 50
}