Wrapping image url in typo3 - 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
}

Related

TYPO3 - FilesProcessor - print out image tag in FLUID Template

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

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]

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

Get current pagetitle in Typo3 in Hmenu

I want to get the pagetitle of the current page I'm on in Typo3. I want to wrap a div - Box for a Hmenu. That works, but I also want the Title in the div to be the title of the current page. My typoscript looks like this
temp.pagetitle = TEXT
temp.pagetitle.field=title
page=PAGE
page.typeNum = 0
page.10.marks.LEFT_MENU = HMENU
page.10.marks.LEFT_MENU {
special = directory
special.value = {$pwcms.linkesMenu.rootSeitenID}
excludeUidList = {$pwcms.linkesMenu.nichtSichtbareSeiten}
stdWrap.preCObject < temp.pagetitle
stdWrap.wrap = <div class="bigBox shadow"> <div class="csc-header csc-header-n1">
<h1 class="csc-firstHeader">temp.pagetitle</h1></div>| </div>
stdWrap.wrap.insertData = 1
If I save these settings and reload the page, the caption in my div Box just says "temp.pagetitle"
I guess it should be some kind of this way:
page = PAGE
page.typeNum = 0
page.10.marks.LEFT_MENU = HMENU
page.10.marks.LEFT_MENU {
special = directory
special.value = {$pwcms.linkesMenu.rootSeitenID}
excludeUidList = {$pwcms.linkesMenu.nichtSichtbareSeiten}
stdWrap.preCObject = TEXT
stdWrap.preCObject.data = page : file
stdWrap.preCObject.wrap = <div class="bigBox shadow"> <div class="csc-header csc-header-n1">
<h1 class="csc-firstHeader"> | </h1> </div> </div>
}

Building a Menu with anchor links as second menu level

I am working on a menu, showing the first level as normal links. The second menu level should be build as anchor menu from the content elements. Inspired by this post I build the following ts:
lib.footerMenu = HMENU
lib.footerMenu {
1 = TMENU
1 {
wrap = <ul class="nav">|</ul>
noBlur = 1
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ATagParams = class="first" |*| |*| class="last"
after.cObject = CONTENT
after.cObject {
table = tt_content
select {
pidInList = this
orderBy = sorting
where = colPos=1
languageField = sys_language_uid
}
wrap = <ul>|</ul>
renderObj = TEXT
renderObj {
field = header
dataWrap = <li>|</li>
}
}
}
}
}
producing something like that ('Arnold ipsum.' and 'Who the hell are you.' being CEs of the Homepage):
<ul class="nav">
<li class="first">Homepage
<ul>
<li>Arnold ipsum.</li>
<li>Who the hell are you.</li>
</ul>
</li>
<li>Team
<ul>
<li>Arnold ipsum.</li>
<li>Who the hell are you.</li>
</ul>
</li>
...
</ul>
The problem now is, that this (pidInList = this) always holds the actual page id and so the anchor menu of the actual page is appended to all main menu items.
How to show the right anchor menu below every main menu?
lib.footerMenu = HMENU
lib.footerMenu {
1 = TMENU
1 {
wrap = <ul class="nav">|</ul>
noBlur = 1
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ATagParams = class="first" |*| |*| class="last"
after.cObject = CONTENT
after.cObject {
table = tt_content
select {
pidInList.stdWrap.cObject = CASE
pidInList.stdWrap.cObject {
key.field = doktype
default = TEXT
default.field = uid
4 = TEXT
4.field = shortcut
}
orderBy = sorting
where = colPos=1
languageField = sys_language_uid
selectFields = uid,pid,header
}
wrap = <ul>|</ul>
renderObj = TEXT
renderObj {
field = header
typolink {
parameter.field = pid
section.field = uid
}
wrap = <li>|</li>
}
}
}
}
}
Though, it might not work on old TYPO3 installations because if I remember correctly pidInList didn't used to have stdWrap. It should work on TYPO3 4.5+.