Reputation: 445
I would like to show content from a fixed page if there’s no content on current page.
An example: On the mainpage (pid=58) In the right col (colPos=31) I have a news plugin with the latest item. On subpages, it’s possible to insert content in the right col (colPos=31). It could be images,text etc. BUT, if the right col is empty I would like to show the news plugin from the mainpage as a fallback option.
This is my TypoScript, but it doesn’t work. Default content from mainpage are not showed, if there's no content from current page.
lib.rightCol-1 = COA
lib.rightCol-1 {
10 = COA
10 {
## Get content from current page.
10 = COA
10 < styles.content.get
## Get content from colPos 31
10.select.where = colPos=31
if.isTrue.current = 1
20 = CONTENT
20 {
## IF no content on current page show content from mainpage
stdWrap.if.isTrue.current = 1
stdWrap.if.negate = 1
table = tt_content
select {
## Get content from mainpage
pidInList = 58
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
}
}
}
Upvotes: 0
Views: 1738
Reputation: 445
Thanks for answer but I couldn't get it to work. Instead this worked:
lib.rightCol-1 = CONTENT
lib.rightCol-1 < styles.content.get
lib.rightCol-1.select.where = colPos=31
lib.rightCol-1 {
stdWrap.ifEmpty.cObject = CONTENT
stdWrap.ifEmpty.cObject {
table = tt_content
select {
pidInList = 58
orderBy = sorting
where = colPos = 31
languageField = sys_language_uid
}
}
}
Upvotes: 0
Reputation: 5840
This can be done using stdWrap.override
. If stdWrap.override
returns something non-empty, this value replaces the normal value stdWrap would return. In your case, this could look like this:
# Fetch the default content from the mainpage with id 58
lib.rightCol-1 = CONTENT
lib.rightCol-1 {
table = tt_content
select {
pidInList = 58
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
# override the content from page 58 with content from the current page,
# but only if there is content on this page
stdWrap.override.cObject = CONTENT
stdWrap.override.cObject {
table = tt_content
select {
pidInList = this
where = colPos=31
orderBy = sorting
languageField = sys_language_uid
}
}
}
You can also create the following behaviour:
This can be done by simply setting slide = -1
to the second CONTENT-Object.
Upvotes: 1