I had an extension called "mbl_newsevent" that work with tt_news. The newsevent ext has his own TS and generates a register button on every news if i enable it. Now the newesevent ext generates a button with a url that contains the current tt_news id.
TS config part:
plugin.tt_news.mbl_newsevent {
registrationLink_typolink {
title.data = LLL:EXT:mbl_newsevent/locallang.xml:registerLinkLabel
parameter = {$powermail.plugin.pid}
parameter.override.field = tx_mblnewsevent_regurl
additionalParams.field = uid
additionalParams.intval = 1
additionalParams.wrap = &tx_powermail_pi1[eventUid]=|
#this returns the correct ID of tt_news for example 99
}
}
But now i need this eventUid in another location of my basic TS. I need this eventUid for my second menu as a parameter
Basic TS:
2 = TMENU
2 {
wrap = <ul class="naviMainLevel2"> | </ul>
NO {
wrapItemAndSub = <li> | </li>
}
ACT = 1
ACT {
wrapItemAndSub = <li class="active"> | </li>
additionalParams.data = GP:tx_ttnews|tt_news
additionalParams.intval = 1
#Here is the part where i need the id from tt_news.mbl_newsevent
#atm it returns &tx_events_pi1[newsUid]=0 correct id would be for example 99
additionalParams.wrap = &tx_events_pi1[newsUid]=|
}
CUR = 1
CUR < .ACT
}
How can i access to another Database (Extension) to get the same id?
temp.xyz = RECORDS
temp.xyz {
tables = tt_news.mbl_newsevent
...
}
Related
it's possible to save the current URL in constants for used this in setup?
URL Example: example.com/de/site1
I need the URL segment: "/de/site2"
Part of my constants:
#--------------------------------------------------
# Site Config
siteConfig {
homePid = 2
footerNaviPid = 4
currentURL =
}
In the setup i build a onPager navi and need the currentURL segment there.
Part of my setup
#---------------------
# Make Sections for OnePager
lib.sectionContentNavi = HMENU
lib.sectionContentNavi {
wrap = |
#entryLevel = 1
special = directory
special.value = 2
#excludeUidList = 25
entryLevel = 1
1 = TMENU
1 {
expAll = 1
noBlur = 1
wrap = <ul>|</ul>
NO {
wrapItemAndSub = <li>|</li>
linkWrap =|
}
ACT = 1
ACT {
wrapItemAndSub = <li class="act">|</li>
linkWrap =|
}
}
2 = TMENU
2 {
expAll = 1
noBlur = 1
wrap = <ul>|</ul>
NO = 1
NO {
doNotLinkIt = 1
linkWrap = <li>|</li>
stdWrap >
stdWrap {
wrap = |
insertData = 1
cObject = TEXT
cObject {
field = nav_title // title
}
}
}
ACT = 1
ACT {
wrapItemAndSub = <li class="act">|</li>
linkWrap =|
}
}
}
A tip from you make me happy :-)
Greets Deukaei
you cant get variable data in your typoscript constants.
you can use variables in your setup (something like GET, POST or ENV).
for easier (or multiple) usage you can store these values in register variables.
But you should not build a-tags in typoscript or fluid on your own.
Try to use typolink or f:link viewhelpers.
in this way you never need to access the current URL as you only link to a page uid (and maybe action paramters and record parameters) and TYPO3 resolves it to the correct path segments.
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 = || ,|
}
}
}
I have to show in my single page: the single and the list of News with the same categories of single new. I have two plugins in my backend page and have tried to assign the categories of single to the list for typoscript, but i could not do it.
This is the code, i used page.x for debug and catch values:
page.100 = TEXT
page.100.data = GP:tx_ttnews|tt_news
page.100.wrap = The single tt_news id is: |
page.100.data = GP:tx_ttnews|cat
page.100.wrap = The category of single is: |
page.110 = TEXT
page.110
{
value = { register:newsCategoryUid }
insertData = 1
wrap = - Categories: |
}
plugin.tt_news
{
categorySelection = { register:newsCategoryUid }
#show only selected categories
categoryMode = 1
}
It's not fully visible what you're trying. I think the best way should to put the cat value inside a temp object. Do you have the plugins inserted by TypoScript or as Content Element? You are using tt_news not news by georg ringer right?
temp.tx_news_catId = TEXT
temp.tx_news_catId.data = GP:tx_ttnews|cat
temp.tx_news_catId.intval = 1
page.110 < temp.tx_news_catId
page.110.wrap = Category: |
plugin.tt_news
{
categorySelection < temp.tx_news_catId
# you need to use data not categorySelection = {...} <- that should
# only work on constants
# but only works if categorySelection capabilities
#categorySelection.data = register:newsCategoryUid
#show only selected categories
categoryMode = 1
}
(Untested TypoScript)
hope this helps you a little bit
PS: Have you checked whether categorySelection has stdWrap capabilities?
I don't really get what you want to do, maybe this helps a bit:
If you want to show in the detail action articles with the same category as the current one, you can use a snippet like this one:
Add this to the Detail.html which will pass the first category uid to the TypoScript object lib.tx_news.relatedByFirstCategory.
<f:if condition="{newsItem.firstCategory}">
<f:cObject typoscriptObjectPath="lib.tx_news.relatedByFirstCategory">{newsItem.firstCategory.uid}</f:cObject>
</f:if>
and the TS:
lib.tx_news.relatedByFirstCategory = USER
lib.tx_news.relatedByFirstCategory {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = News
pluginName = Pi1
vendorName = GeorgRinger
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
relatedView = 1
detailPid = 31
useStdWrap := addToList(categories)
categories.current = 1
categoryConjunction = or
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = 78
}
}
I have taken this from the manual.
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.
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