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)
Related
I'm trying to show informations of a single Fe user with typoscript. Everything is working fine except I can't get the image path. How can I get the path to the associated image?
Thanks for pointing me in the right direction.
Noël
EDIT:
Hi, I'm using TYPO3 version 9.5.21.
The TS code to get the fe user data:
lib.feUserLink = CONTENT
lib.feUserLink {
table = fe_users
select {
pidInList = 16
max = 10
orderBy = last_name DESC
}
renderObj = COA
renderObj {
10 = TEXT
10.field = username
10.typolink {
parameter = 483
additionalParams.dataWrap = &user={field:uid}
useCacheHash = 1
}
10.wrap = |</br>
20.### here I'd like to get the image path###
}
}
In TypoScript you can use the objects FILES and IMAGE in order to get an image, you can try something like this I guess :
lib.feUserLink = CONTENT
lib.feUserLink {
table = fe_users
select {
pidInList = 16
max = 10
orderBy = last_name DESC
}
renderObj = COA
renderObj {
10 = TEXT
10.field = username
10.typolink {
parameter = 483
additionalParams.dataWrap = &user={field:uid}
useCacheHash = 1
}
10.wrap = |</br>
20 = FILES
20 {
references {
table = fe_users
uid.data = {field:uid}
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid
}
}
}
}
I'm trying to use different Frontend-Layouts in TYPO3. So I'm using this fancy TypoScript:
page {
bodyTag = <body>
10= CASE
10.key.field=layout
# Standardtemplate
10.0 = TEMPLATE
10.0.template = FILE
10.0.template.file = fileadmin/template/content_template.html
10.0.workOnSubpart = DOCUMENT_BODY
# Variante 1:
10.1 = TEMPLATE
10.1.template = FILE
10.1.template.file = fileadmin/template/index_template.html
10.1.workOnSubpart = DOCUMENT_BODY
includeJSFooter {
jquery = fileadmin/template/js/jquery.js
bootstrap = fileadmin/template/js/bootstrap.min.js
app = fileadmin/template/js/app.js
}
includeCSS {
robotoFont = https://fonts.googleapis.com/css?family=Roboto:100,400
robotoFont.external = 1
robotoFont.media = all
bootstrapCore = fileadmin/template/css/bootstrap.min.css
bootstrapCore.media = all
}
}
This is not working yet. Every single page is completely. Only a white page appears. I'm using TYPO3 7.6.16. Is there any issue in my code above?
It think you are looking for this just place it in the PAGE-Element and rename the Path and also create some BackendLayouts named as value in layout 1. 2. 3. e.g. hope this will help:
10 = FLUIDTEMPLATE
10 {
file = fileadmin/templates/Page/Standard.html
partialRootPath = fileadmin/templates/Partials/
variables {
layout = CASE
layout {
key.field = backend_layout
key.ifEmpty.data = levelfield:-2, backend_layout_next_level, slide
1 = TEXT
1.value = startpage
2 = TEXT
2.value = subpage
3 = TEXT
3.value = subpagespecial
default = TEXT
default.value = subpage
}
content = CONTENT
content {
table = tt_content
select.orderBy = sorting
select.where = colPos=0
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
header = CONTENT
header {
table = tt_content
select.orderBy = sorting
select.where = colPos=1
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
content2 = CONTENT
content2 {
table = tt_content
select.orderBy = sorting
select.where = colPos=3
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
contentfull = CONTENT
contentfull {
table = tt_content
select.orderBy = sorting
select.where = colPos=2
select.languageField = sys_language_uid
select.includeRecordsWithoutDefaultTranslation = 1
}
}
}
Please add a default variant in the CASE object. It may be that pages which are created anew do not have a '0' in its 'layout' column.
Did you verify that the subpart markers are spelled correctly?
<!-- ###DOCUMENT_BODY### begin -->
Your HTML template
<!-- ###DOCUMENT_BODY### end -->
You could simplify your TypoScript template:
page {
10 = TEMPLATE
10.template = FILE
10.template.file = CASE
10.template.file {
key.field = layout
default = TEXT
default.value = fileadmin/template/content_template.html
1 = TEXT
value = fileadmin/template/index_template.html
}
10.workOnSubpart = DOCUMENT_BODY
}
I must set plugin.tt_news._DEFAULT_PI_VARS.tt_news to show the latest news by default. So I get the uid of the latest news via CONTENT.
temp.newsUid = CONTENT
temp.newsUid {
table = tt_news
select {
pidInList = 12345
orderBy = datetime DESC
join = tt_news_cat_mm ON tt_news_cat_mm.uid_local = tt_news.uid
where = tt_news_cat_mm.uid_foreign = 4711 AND tt_news.deleted = 0 AND tt_news.hidden = 0
max = 1
}
renderObj = COA
renderObj {
10 = TEXT
10.field = uid
}
}
plugin.tt_news._DEFAULT_PI_VARS.tt_news = temp.newsUid
will not work. But how can I do it?
This will work:
plugin.tt_news._DEFAULT_PI_VARS.tt_news.stdWrap.cObject < temp.newsUid
I'm showing all content from the subpages on one page:
lib.allPid = COA
lib.allPid {
10 = HMENU
10 {
#entryLevel = 1
special = directory
special.value = 115
1 = TMENU
1 {
expAll = 1
NO.doNotShowLink = 1
NO.allStdWrap.field = uid
NO.allStdWrap.wrap = |,
}
2 < .1
}
}
lib.allContent = CONTENT
lib.allContent {
table = tt_content
select {
pidInList.cObject < lib.allPid
where = colPos = 0
orderBy = pid DESC
}
}
Here the content is ordere by pid DESC. But I'd like to order the content from the subpages by their position in the pagetree. So that the user can define his own ordering.
I tried:
lib.allContent = CONTENT
lib.allContent {
table = tt_content
select {
pidInList.cObject < lib.allPid
leftjoin = pages ON (tt_content.pid = pages.pid)
where = tt_content.colPos = 0
orderBy = pages.sorting ASC
}
}
Didn't work...
Does anyone know how to do this? Thanks in advance!
You are on a good way, but you made the join wrong.
In your code it is tt_content.pid = pages.pid, and this one is wrong. The pid value in tt_content is the uid from the pages.
You need to change your script so:
lib.allContent = CONTENT
lib.allContent {
table = tt_content
select {
pidInList.cObject < lib.allPid
leftjoin = pages ON (tt_content.pid = pages.uid)
where = tt_content.colPos = 0
orderBy = pages.sorting ASC
}
}
I tested it, and it worked on a test instance.
I would like to read out a page's system categories for further use with tx_news (to display news that have the same categories as the page - as tx_news is using system categories).
I was looking for a native solution, hopefully via getText, something like:
plugin.tx_news.settings.categories.data = page:categories
but that doesn't seem to exist yet
Also, I tried to simplify the query by using sys_category_records_mm, which contains all the information needed for that case, but TYPO3 complains that "there is no entry in the $TCA array":
lib.categoryUid = CONTENT
lib.categoryUid {
wrap = kategorien:|
table = sys_category_record_mm
select {
selectFields = uid
where = uid_foreign = {TSFE:id}
where.insertData = 1
}
renderObj = TEXT
renderObj {
field = uid
wrap = |,
}
}
So that would be nice, but it's not allowed.
Here's a solution that works in my setup. The editor chooses categories for the page, and gets all news items that belong to the category.
temp.categoryUid = CONTENT
temp.categoryUid {
table = pages
select {
// dontCheckPid doesn't exist for CONTENT objects, so make it recursive from root page (or pidInList.data = leveluid:-2
pidInList = {$pidRoot}
recursive = 99
selectFields = sys_category.uid as catUid
join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {TSFE:id}
where.insertData = 1
// not necessary for this use case
// orderBy = sys_category.sorting
}
renderObj = TEXT
renderObj {
field = catUid
// Hack: if there are no cats selected for a page, all news are displayed
// so I just pass a catUid that's quite unlikely
wrap = 999999,|,
}
}
lib.newstest = USER
lib.newstest {
userFunc = tx_extbase_core_bootstrap->run
extensionName = News
pluginName = Pi1
switchableControllerActions {
News {
1 = list
}
}
settings < plugin.tx_news.settings
settings {
limit = 5
orderBy = datetime
orderDirection = desc
detailPid = {$pidNachrichtenDetail}
overrideFlexformSettingsIfEmpty := addToList(detailPid)
startingpoint = {$pidNachrichtenRecords}
// for use in my fluid template
// pluginTitle = {$llAktuell}
// latest = 0
// recordType = aktuell
// https://forge.typo3.org/issues/52978
useStdWrap = categories
categories.override.cObject < temp.categoryUid
categoryConjunction = or
}
view =< plugin.tx_news.view
}
What is unclear to me still is if recursive = 1 in the select has no setback. Actually, I don't want to check for the current page's parent uid at all, but WHERE pages.pid IN ({current pid}) is always inserted automatically. Therefore the recursive = 1.
I found this example (in German) and modified it to display the category UIDs.
The following TypoScript will display the UIDs of all categories for the current page seperated by a comma.
10 = CONTENT
10 {
table = pages
select {
uidInList.field = uid
pidInList = 1 # UID or list of UIDs, where your categories are saved
selectFields = sys_category.uid as catUid
join = sys_category_record_mm ON pages.uid = sys_category_record_mm.uid_foreign JOIN sys_category ON sys_category.uid = sys_category_record_mm.uid_local
where = sys_category_record_mm.tablenames = 'pages' AND sys_category_record_mm.uid_foreign = {field:uid}
where.insertData = 1
orderBy = sys_category.sorting
}
renderObj = TEXT
renderObj {
field = catUid
wrap = |,
}
# HACK
# If category is empty, the mechanism below won't work
# As long as I don't know how to query if this is empty or not,
# just add an imaginary extra category!
wrap = 12345,|
}
Unfortunately you have to set pidInList manually to a list of UIDs, where your categories are stored.
Looking for the cat-id of a page:
I did it this way:
lib.cat = CONTENT
lib.cat {
wrap = |
table = sys_category
select {
pidInList = 1
selectFields = sys_category.uid, sys_category.title
max = 1
join = sys_category_record_mm ON(sys_category_record_mm.uid_local = sys_category.uid)
where = sys_category_record_mm.tablenames='pages'
andWhere.dataWrap = sys_category_record_mm.uid_foreign = {TSFE:id}
}
renderObj = COA
renderObj {
10 = TEXT
10 {
field = uid
wrap = class="category|
}
20 = TEXT
20 {
field = title
case = lower
stdWrap.noTrimWrap = | |"|
}
}
}