How to put out a record with all categorie-titles connected to it - typo3

On a website, various records are to be output as teasers. Each record is assigned to one or more categories. In the teasers, the titles of all categories assigned to the respective record should be displayed.
I tried this with a Typoscript (see below), in which I linked the database query of tt_content via a JOIN with sys_category and sys_category_record_mm.
But now for records that have multiple categories assigned to them, the corresponding teasers are output multiple times, i.e. once per category.
Fluid:
<f:if condition="{data.tx_mask_cnt_mag_teaser_records}">
<f:for each="{data.tx_mask_cnt_mag_teaser_records}" as="data_item">
<f:cObject typoscriptObjectPath="lib.magteaser" data="{dsuid: data_item.uid, recid: data_item.records, reclimit: 2, tstype: 1, syscats: data.tx_mask_cnt_mag_teaser_cats}" />
</f:for>
</f:if>
Typoscript:
lib.magteaser = COA
lib.magteaser {
wrap = |
5 = LOAD_REGISTER
5 {
dTstype.data = field:tstype // Different Teaser-Types
dSyscats.data = field:syscats // List of all categories to consider
}
10 = CONTENT
10 {
table = tt_content
select {
pidInList = 13 // Folder in which the records are stored
uidInList.data = field:recid
recursive = 2
selectFields.dataWrap = *, FIND_IN_SET(`tt_content`.`uid`,'{field:recid}') AS reclist_sortby
join = sys_category_record_mm ON (sys_category_record_mm.uid_foreign = tt_content.uid) JOIN sys_category ON (sys_category_record_mm.uid_local = sys_category.uid)
where = tt_content.hidden=0
where = tt_content.CType='mask_cnt_textpic_uni'
where.data = field:syscats
# where.intval = 1
where.wrap = sys_category_record_mm.uid_local IN (|)
orderBy = reclist_sortby
}
renderObj = COA
renderObj {
5 = LOAD_REGISTER
5 {
# Count variable for a CASE (see below) to format the first data record differently from the remaining data records.
dsCounter.stdWrap.dataWrap = {register:dsCounter} + 1
dsCounter.prioriCalc = intval
}
10 = CASE
10 {
key.data = register:dTstype
default = COA
default {
wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>
[...]
}
# 1 Titelbild und 2 Standard-Teaser
1 = COA
1 {
wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>
[...]
}
# 1 Top-Teaser und 2 Standard-Teaser
2 = COA
2 {
10 = CASE
10 {
key.data = register:dsCounter
# Standard-Teaser
default = COA
default {
wrap = <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 magteaser-std">|</div>
10 = TEXT
10 {
wrap = Kategorie (def): |
value.dataWrap = {field:title}
}
[...]
}
# Top-Teaser
1 = COA
1 {
wrap = <div class="col-12 magteaser-top">|</div>
10 = TEXT
10 {
wrap = Kategorie (1): |
value.dataWrap = {field:title}
}
[...]
}
}
}
}
}
}
}
Does anyone have a tip for me on how to solve the problem?
Many thanks in advance for your help!
Typo3 V.9.5.8

With the join you generate a matrix, with a 'record' for each combination.
The correct handling would be to handle the mutiple categories in the renderObj:
build a part where all categories for this tt_content record are printed.
conceptual structure:
10 = CONTENT
10 {
table = tt_content
select {
:
// without JOIn
:
}
renderObj = COA
renderObj {
:
50 = CONTENT
50 {
table = sys_categories
SELECT {
join = sys_category_record_mm ON (sys_category_record_mm.uid_foreign = ###CONTENT_UID###) AND (sys_category_record_mm.uid_local = sys_category.uid)
markers {
// context is current tt_content record:
CONTENT_UID.field = uid
}
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = || ,|
}
}
}

Related

Use a variable in Typoscript "select"

I try to get an author of a Typo3 site and after this i try to fill a Typo3 select (typoscript) with the resulting ID.
Its somehow working, but i can not use the lib oder variable as datasource of another select
I tryed to play arround with LOAD_REGISTER or marker. But i think it has to be a way to use a select result or another "lib" result in a select.
Here is my code:
// Returns succsessfully "neuz8" and i can use this in fluid
lib.author = TEXT
lib.author.data = page:author
lib.Authornavigation = CONTENT
lib.Authornavigation {
stdWrap.required = 1
table = be_users
select {
uidInList = 0
pidInList = root
selectFields = be_users.uid as id, be_users.realName as rn, be_users.profile_pid as prid
where = be_users.profile_pid != '0'
andWhere = be_users.realName={lib.author} // Is not working, why?
// I tryed: combinations of andWhere.data or lib.author.data,
// with and without {},
// with LOAD_REGISTER,
// with "markers",
//andWhere = be_users.realName='neuz8' < this works and returns "39", the correct ID
andWhere.wrap =
markers {
//author.data = {page:author}
}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = prid
10.wrap2 = ###SPLITTER### |
}
stdWrap.split {
token = ###SPLITTER###
cObjNum = 1 |*| 2 |*| 1
1.current = 1
2.current = 1
2.wrap = |,
}
}
This should work
replace
// andWhere = be_users.realName={lib.author} // Is not working, why?
with
andWhere = be_users.realName=
andWhere.postCObject < temp.author
You can try select.markers:
page.60 = CONTENT
page.60 {
table = tt_content
select {
pidInList = 73
where = header != ###whatever###
orderBy = ###sortfield###
markers {
whatever.data = GP:first
sortfield.value = sor
sortfield.wrap = |ting
}
}
}
Docs » Functions » select (see part markers)

TypoScript / Typo3: How to build sub-content of a page using header_link value?

How can I build a sub-content (nested content) of a page using typoscript with reference to the parent's header_link field?
Desired output is something like:
<h1>Title of parent</h1>
<p class="prt">Body of parent</p>
<h3>Title of Child</h3>
<p class="cld">Contents of child</p>
Sample of my Typoscript:
temp.myParentVal = CONTENT
temp.myParentVal {
table = tt_content
select {
begin = 1
orderBy = sorting
where = (colPos = 1)
}
renderObj = COA
renderObj {
10 = TEXT
10 {
required = 1
wrap = <h1> | </h1>
stdWrap.field = header
}
20 = TEXT
20 {
required = 1
wrap = <p class="prt"> | </p>
stdWrap.field = bodytext
}
# #
# WHAT SHOULD I DO HERE TO SHOW THE CHILD CONTENT OF THIS PAGE #
# (REFERENCED BY header_link FIELD IN THE PARENT'S ROW), #
# WHICH HAS THE FORMAT OF <child_pid#child_uid>, EG.'11#28' #
# #
stdWrap.wrap = <div> | </div>
}
I would like to make use of parent's header_link field value to generate the content for the child. (I'm using TYPO3 v. 6.2.14)
You can use a nested CONTENT element and split the header_link via Regex like this:
30 = CONTENT
30 {
table = tt_content
select {
uidInList {
field = header_link
stdWrap.replacement.10 {
search = /^.+#/
replace =
useRegExp = 1
}
}
pidInList {
field = header_link
stdWrap.replacement.10 {
search = /#.+$/
replace =
useRegExp = 1
}
}
}
renderObj = COA
renderObj {
10 = TEXT
10.value {
required = 1
wrap = <h3> | </h3>
field = header
}
20 = TEXT
20.value {
required = 1
wrap = <p class="cld"> | </p>
field = bodytext
}
}
}
Also, I wanted to suggest that you use the field property directly on the TEXT elements (which works). But I looked it up in the docs:
stdWrap properties are available on the very rootlevel of the object. This is non-standard! You should use these stdWrap properties consistently to those of the other cObjects by accessing them through the property "stdWrap".
https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Text/Index.html
As value is a stdWrap object, you could use it as I did above.

Typo3 Powermail Prefill

Im using Typo3 and got 2 Powermail Forms on a Hotel Page.
One small form on every Page where you can put the checkin and checkout date.
After this you will be redirected to the main form.
How can i prefill the daterecords from the small after the redirect in the mainform?
Both forms have the same variable names {checkin} and {checkout}
Thanks
Try it..
plugin.tx_powermail.settings.setup.prefill {
# Fill field with marker {current_date}
current_date = TEXT
current_date{
data = date : U
strftime = %d-%m-%Y %H:%M:%S
}
form2date = TEXT
form2date{
data = date : U
strftime = %d-%m-%Y %H:%M:%S
}
seminar = CONTENT
seminar {
table = tx_news_domain_model_news
select.pidInList = 118
select.where.stdWrap.cObject = TEXT
select.where.stdWrap.cObject.data = GP:tx_news_pi1|news
select.where.stdWrap.cObject.wrap = uid = |
select.where.stdWrap.cObject.insertData =1
renderObj = COA
renderObj {
10 = TEXT
10.dataWrap ={field:title}
}
}
price = CONTENT
price {
table = tx_news_domain_model_news
select.pidInList = 118
select.where.stdWrap.cObject = TEXT
select.where.stdWrap.cObject.data = GP:tx_news_pi1|news
select.where.stdWrap.cObject.wrap = uid = |
select.where.stdWrap.cObject.insertData =1
renderObj = COA
renderObj {
10 = TEXT
10.dataWrap ={field:price}
}
}
location = CONTENT
location {
table = tx_news_domain_model_news
select.pidInList = 118
select.where.stdWrap.cObject = TEXT
select.where.stdWrap.cObject.data = GP:tx_news_pi1|news
select.where.stdWrap.cObject.wrap = uid = |
select.where.stdWrap.cObject.insertData =1
renderObj = COA
renderObj {
10 = TEXT
10.dataWrap ={field:tx_roqnewsevent_location}
}
}
event_startdate = CONTENT
event_startdate {
table = tx_news_domain_model_news
select.pidInList = 118
select.where.stdWrap.cObject = TEXT
select.where.stdWrap.cObject.data = GP:tx_news_pi1|news
select.where.stdWrap.cObject.wrap = uid = |
select.where.stdWrap.cObject.insertData =1
renderObj = COA
renderObj {
10 = TEXT
10.value.field = tx_roqnewsevent_startdate
10.value.date = d-m-Y
#10.strftime = %d-%m-%Y
}
}
}
Hi try add (width js on submit action) in form action url or redirect url width parametrs [checkin]="" and [checkout]="". Like this
<form class="form-horizontal powermail_form powermail_form_1" action="index.php?id=5&checkin=25.05.15&checkout=25.06.15" method="post">
...
for test try use url "yousite.com/index.php?id=5?checkin=25.05.15&checkout=25.06.15" fields in form must be fill.
Where "5" - your main form page id

Refer to media field of original language in TYPO3

In TYPO3 6.2 (just upgraded from 4.5) I have a TMENU with Images, using a cObject in NO to build the menu as desired.
It works in the main language, but in the second language's frontend, the images are not rendered - unless they are filled in in the second language's media field.
How do you force FILES to refer to the media field of the original language?
In my case, always. In other cases, a fallback solution may be desired.
temp.menu = COA
temp.menu {
wrap = <div class="teasermenu">|</div>
15 = HMENU
15 {
special = list
//special.value.cObject < temp.displayedpages
// recieves a list, such as:
special.value = 1,3,9
1 = TMENU
1 {
noBlur = 1
maxItems = 16
wrap = <ul>|</ul>
NO {
wrapItemAndSub = <li>|</li>
ATagBeforeWrap = 1
ATagParams = || || || || class="red" |*| |*|
stdWrap.cObject=COA
stdWrap.cObject{
10 = TEXT
10.field = nav_title // title
10.wrap = <strong class="teasermenu_header">|</span></strong>
20=FILES
20{
if{
isInList.field = uid
//value.cObject < temp.displayedpages_wimage
// receives another list, like:
// value = 3,9
}
references {
table=pages
fieldName=media
}
renderObj=IMAGE
renderObj{
file{
height=80
maxH=80
import.data=file:current:publicUrl
}
altText.field=title
titleText.field=title
}
}
}
}
}
}
}
PS there are many media field / FAL fallback related bugs on forge, e.g. this one. But I have a feeling this might be a simpler issue.
mergeIfNotBlank is gone now, the current solution (TYPO3 8.7) seems to be to set
$GLOBALS['TCA']['pages']['columns']['media']['config']['behaviour']['allowLanguageSynchronization'] = 1;
But based on https://forum.typo3.org/index.php/t/217033/-typo3-ug-freiburg-media-feld-in-den-seiteneigenschaften (thanks) there's this snippet. It also works with cropVariants:
temp.bgimg_wide = CONTENT
temp.bgimg_wide{
table = sys_file_reference
select{
pidInList = {$pids.pidHome}
where = tablenames='pages' AND fieldname='media'
orderBy = sorting_foreign
languageField = 0
selectFields = uid_local
max = 1
begin = 0
}
renderObj = FILES
renderObj{
files.stdWrap.field = uid
renderObj = IMG_RESOURCE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 1600
cropVariant = bgimg_wide
}
}
}
}
}
This works!
With TYPO3 CMS 7.6 you need to exclude field media of table pages from [FE][pageOverlayFields] as set in ~/typo3_src-7.6.10/typo3/sysext/core/Configuration/DefaultConfiguration.php, until it is solved - see forge issue https://forge.typo3.org/issues/65863
Write in your AdditionalConfiguration
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = 'uid,doktype,title,subtitle,nav_title,keywords,description,abstract,author,author_email,url,urltype,shortcut,shortcut_mode';
or in your Extension ext_localconf.php
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields'] = str_replace(',media', '', $GLOBALS['TYPO3_CONF_VARS']['FE']['pageOverlayFields']);
Based on Urs' answer, here comes a slight variation.
lib.getCurrentPageMedia = CONTENT
lib.getCurrentPageMedia {
table = sys_file_reference
select{
pinInList = root, this
where = tablenames='pages' AND fieldname='media' AND uid_foreign=###pid###
orderBy = sorting_foreign
languageField = 0
selectFields = uid_local
max = 1
begin = 0
markers {
pid.data = TSFE:id
}
}
renderObj = TEXT
renderObj.stdWrap.field = uid
}
Fluid:
<f:image src="{f:cObject(typoscriptObjectPath:'lib.getCurrentPageMedia')}" alt="" width="400c" height="400c" treatIdAsReference="1" class="img-responsive" />
Advantage: you can define cropping, alt-text, etc. in your template.
You might want to try to set the TCA of the media field to l10n_mode => mergeIfNotBlank .
http://docs.typo3.org/typo3cms/TCAReference/Reference/Columns/Index.html#columns-properties-l10n-mode
Put this into the typo3conf/AdditionalConfiguration.php:
$TCA['pages']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
Since this issue is from Februari, you've probably found a solution by now. I just ran into this issue and solved it by including:
$GLOBALS['TCA']['pages_language_overlay']['columns']['media']['l10n_mode'] = 'mergeIfNotBlank';
in my ext_tables.php

The detailed view of the last item of a list build by TypoScript is always blank

Here's the TypoScript code.
lib.membersList = CONTENT
lib.membersList{
table = tt_address
select{
pidInList = {$membersStorageFolder}
orderBy = zip, last_name
}
wrap = <div class="membersList">|</div>
renderObj = COA
renderObj{
10 = FLUIDTEMPLATE
10{
file = fileadmin/templates/ext/memberslist/templates/membersList.html
variables{
portrait = IMAGE
portrait{
file.import = uploads/pics/
file.import {
field = image
listNum = 0
}
file.height = 105
file.width = 105c
stdWrap.typolink{
parameter = {$membersPageId}
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
#returnLast = url
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
}
lastName = TEXT
lastName.field = last_name
lastName.typolink{
parameter.data = TSFE:id
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
firstName = TEXT
firstName.field = first_name
firstName.typolink{
parameter.data = TSFE:id
additionalParams.dataWrap = &ts_addresslist[showUid]={field:uid}
# The cache hash is needed to display the right content, since we are not running as USER_INT
useCacheHash = 1
}
title = TEXT
title.field = title
organisation = TEXT
organisation.field = company
country = TEXT
country.field = country
city = TEXT
city.field = city
}
}
}
stdWrap.override.cObject = CONTENT
stdWrap.override.cObject{
table = tt_address
select {
andWhere.data = GP:ts_addresslist|showUid
# Make sure there is no SQL injection!
andWhere.intval = 1
andWhere.wrap = uid=|
orderBy = last_name ASC
pidInList = {$membersStorageFolder}
}
wrap = <div class="membersDetail">|</div>
renderObj = FLUIDTEMPLATE
renderObj{
file = fileadmin/templates/ext/memberslist/templates/membersDetail.html
variables{
portrait = IMAGE
portrait{
file.import = uploads/pics/
file.import {
field = image
listNum = 0
}
file.height = 105
file.width = 105c
}
lastName = TEXT
lastName.field = last_name
firstName = TEXT
firstName.field = first_name
title = TEXT
title.field = title
organisation = TEXT
organisation.field = company
country = TEXT
country.field = country
city = TEXT
city.field = city
detail = TEXT
detail.field = description
}
}
renderObj.stdWrap.append = TEXT
renderObj.stdWrap.append{
value = << Back to list
typolink.parameter = {$membersPageId}
}
}
stdWrap.override.if {
isTrue.data = GP:ts_addresslist|showUid
isTrue.intval = 1
}
}
Everything is working fine. The list is displayed as it should. The detailed view also except for the last item. When I click on it, the detailed view displays a blank page. No information, as if the query fetched nothing.
Here are the templates, very simple though.
membersList.html
<section>
{portrait -> f:format.raw()}
<div class="memberDetail">
<h1>{lastName -> f:format.raw()} {firstName -> f:format.raw()}</h1>
<h2>{title} - {organisation}</h2>
<h3>{country} - {city}</h3>
</div>
</section>
membersDetail.html
<section>
{portrait -> f:format.raw()}
<div class="memberDetail">
<h1>{lastName} {firstName}</h1>
<h2>{title} - {organisation}</h2>
<h3>{country} - {city}</h3>
</div>
<div class="bio">
{detail}
</div>
</section>
Your code looks right so far. For debugging purpose add it directly to page object.
page.38388383 = CONTENT
page.38388383 {
table = tt_address
select{
pidInList = {$membersStorageFolder}
orderBy = zip, last_name
}
wrap = <div class="membersList">(|)</div>
renderObj = COA
renderObj{
10 = TEXT
10.field = uid
10.wrap = (|),
}
}
With this, you should get a comma separated list of all tt_address records without sideeffects. If that does not work, check on database level if everything is correct. Perhaps you some trouble with language, workspace or so...?
If this works like expected, you can replace your renderObj with this one and see what happens.
If expect that there is no crazy loop effect - but some CMS sideeffects (like missing rights, language, workspace version etc.).