TypoScript condition to check if specific list_type is on a page - typo3

I try to have a condition in TypoScript to find out if a certain list_type is on the page (plugin). In the docs I can't find anything about that. Is it even possible at all?

lib.hasNewsOnPage = TEXT
lib.hasNewsOnPage {
value = 1
if.isTrue.numRows {
table = tt_content
select.where.dataWrap = pid = {TSFE:id} AND colPos = 1 AND list_type = 'news_pi1'
}
}

Try this:
Return 1 if the plugin News is fund on the current page (colpos 1)
lib.hasNewsOnPage = TEXT
lib.hasNewsOnPage {
value = 0
stdWrap {
override {
cObject = CONTENT
cObject {
table = tt_content
select {
where = colPos=1 AND list_type = 'news_pi1'
max = 1
}
renderObj = TEXT
renderObj {
value = 1
}
}
}
}
}

Related

Get an image from a UID using typoscriptObjectPath in a Fluid template?

In my Fluid template I have a uid of a category.
How can I get an image from a field on that category?
I've tried <f:cObject typoscriptObjectPath="lib.catImage" data="{myuid}" />
Then something like:
lib.catImage = CONTENT
lib.catImage {
table = sys_category
current = 1
select {
fieldName = cat_image
}
renderObj {
???
}
}
You don't want to get CONTENT but FILES:
lib.catImage = FILES
lib.catImage {
maxItems = 1
references {
table = sys_category
uid.data = field:uid
fieldName = images
}
renderObj = TEXT
renderObj {
stdWrap.data = file:current:uid
}
}
And call it via <f:cObject typoscriptObjectPath="lib.catImage" data="{uid: {myuid}}" />

How to get first image in tt_content for meta og:image

I'm trying to fetch the first existing image in tt_content to be used in Open Graph (og:image) if any images in tt_content.
page.headerData {
1 = COA
1 {
10 = FILES
10 {
references {
table = tt_content
uid.field = uid
fieldName = image
}
renderObj = TEXT
renderObj {
typolink {
parameter.data = file:current:publicUrl
forceAbsoluteUrl = 1
returnLast = url
}
wrap = |,
}
stdWrap {
listNum = 0
# Use logo image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = typo3conf/ext/my_ext/Resources/Public/Images/logo.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <meta property="og:image" content="|">
}
}
}
}
The code above only returns the fallback (logo). Great for pages and tt_content without images, but I would expect different from pages with image(s) in tt_content.
I report here the nice snippet found on https://docs.typo3.org/m/typo3/docs-snippets/master/en-us/2014/Index.html#add-facebook-open-graph-og-image-metatags-for-content-elements-with-typo3-6-0-and-fal
I simplified it a bit; hope it is not too much simplified but it should work:
page.headerData.200 = CONTENT
page.headerData.200 {
table = tt_content
select {
where = {#colPos}=0
selectFields = uid
}
renderObj = FILES
renderObj {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maxItems = 1
renderObj = TEXT
renderObj {
data = file:current:publicUrl
stdWrap {
wrap = <meta name="og:image" content="|" >
}
}
}
}
Here is #riccardo-de-contardi's snippet with a fallback
page.headerData.1569221029 = CONTENT
page.headerData.1569221029 {
table = tt_content
select {
where = {#colPos}=0
selectFields = uid
}
renderObj = FILES
renderObj {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maxItems = 1
renderObj = TEXT
renderObj {
data = file:current:publicUrl
stdWrap {
wrap = |,
}
}
}
stdWrap {
listNum = 0
# Use logo image if none is available
ifEmpty.cObject = TEXT
ifEmpty.cObject.typolink {
parameter = typo3conf/ext/my_ext/Resources/Public/Images/logo.png
forceAbsoluteUrl = 1
returnLast = url
}
wrap = <meta property="og:image" content="|">
}
}

My manually built TYPO3 lightbox isn't working properly

In a COA, I have this TypoScript to add an image linked to a larger copy of itself. But the Javascript plugin I'm using (Colorbox) isn't able to resize the image properly.
20 = CONTENT
20 {
wrap = <div class="lightbox clearfix">|</div>
required = 1
table = tt_content
select.languageField = sys_language_uid
select.where = colPos = 2
select.selectFields = bodytext,image,header
renderObj=COA
renderObj{
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid // file:current:uid
file.width=300c
file.height=300c
imageLinkWrap = 1
imageLinkWrap {
enable = 1
width = 1600m
height = 1600m
JSwindow = 0
linkParams.ATagParams {
// title.data =
dataWrap = class = "lightbox-group" title="{file:current:description}"
}
}
}
}
}
}
What's up?
Here's the correct TypoScript. I'm sharing it because it is a legacy weirdness others might stumble upon too.
You have to set imageLinkWrap.directImageLink = 1, else imageLinkWrap won't deliver the image itself, but a HTML page containing that image!
20 = CONTENT
20 {
wrap = <div class="lightbox clearfix">|</div>
required = 1
table = tt_content
select.languageField = sys_language_uid
select.where = colPos = 2
select.selectFields = bodytext,image,header
renderObj=COA
renderObj{
10 = FILES
10 {
required = 1
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:originalUid // file:current:uid
file.width=300c
file.height=300c
imageLinkWrap = 1
imageLinkWrap {
enable = 1
width = 1600m
height = 1600m
directImageLink = 1
JSwindow = 0
linkParams.ATagParams {
// title.data =
dataWrap = class = "lightbox-group" title="{file:current:description}"
}
}
}
}
}
}

tt_news category image url

I need the url of the image from tt_news category to fill conf.tt_news.10.stdWrap.ifEmpty. Does anyone have an idea. My approach
lib.catimage = TEXT
lib.catimage {
table = tt_news_cat
select {
pidInList = 2
andWhere {
data = GPVar:tx_ttnews|cat
....????
page.headerData {
15 = RECORDS
15 {
source.data = GPvar:tx_ttnews|tt_news
tables = tt_news
conf.tt_news = COA
conf.tt_news.10 = IMG_RESOURCE
conf.tt_news.10.file {
width = 403
import = uploads/pics/
import.field = image
import.listNum = 0
}
conf.tt_news.10.stdWrap.ifEmpty < lib.catimage
wrap = <link rel="image_src" href="{$BaseUrl}|" />
}
}
I have a new approach, but do not see the error. If I take out the commented brace the path is correct but the syntax of the script is incorrect. The first part also does not work anymore. Here the modified version.
page.headerData {
15 = RECORDS
15 {
source.data = GPvar:tx_ttnews|tt_news
tables = tt_news
conf.tt_news = COA
conf.tt_news.10 = IMG_RESOURCE
conf.tt_news.10.file {
width = 403
import = uploads/pics/
import.field = image
import.listNum = 0
}
conf.tt_news.10.stdWrap.ifEmpty.cObject = CONTENT
conf.tt_news.10.stdWrap.ifEmpty.cObject {
table = tt_news_cat
select {
selectFields = image
pidInList = 2
languageField = sys_language_uid
where = deleted=0 AND hidden=0
andWhere {
data = GPvar:tx_ttnews|category
wrap = uid=|
intval = 1
}
}
#}
renderObj = TEXT
renderObj.field = image
}
wrap = <link rel="image_src" href="{$BaseUrl}|" />
}
}

TYPO3 6.0: Render images of current page from border column in FAL

I've have the following snippets and I don't get it to work.
COL3 = FILES
COL3 {
references {
table = tt_content
uid = 14
fieldName = image
}
renderObj = TEXT
renderObj {
data = file:current:publicUrl
wrap = <img src="|">
}
}
Snippet works so far, but I want to use it with current page & colPos = 3. So something like:
table = tt_content
select {
where = colPos = 3
orderBy = sorting
languageField = sys_language_uid
}
It feels like I've tried almost everything.
I really appreciate every help I can get...
Thank's alot!!
That's sounds better to me :
COL3 = CONTENT
COL3 {
table = tt_content
select {
where = colPos = 3
}
renderObj = FILES
renderObj {
references {
table = tt_content
fieldName = image
}
renderObj = IMAGE
renderObj {
file.import.data = file:current:publicUrl
}
}
}
I presume the select attribute does not work with references.
Try this solution (not tested) to use with any content element.
...
references {
table = tt_content
uid.data = uid
fieldName = image
}
Another idea:
COL3 = CONTENT
COL3 {
table = tt_content
select {
where = colPos = 3
}
renderObj = FILES
renderObj {
references {
table = tt_content
fieldName = image
}
renderObj = TEXT
renderObj {
data = file:current:publicUrl
wrap = <img src="|">
}
}
}