I have a page with a news plugin that gives only news of a chosen category, in the sidebar of that page I use the image that is loaded for the category, i do that this way:
# cat detail page Images
lib.catImg = FILES
lib.catImg {
references {
table = sys_category
uid.data = GP:tx_news_pi1|overwriteDemand|categories
fieldName = images
treatIdAsReference = 1
}
begin = 0
maxItems = 5
renderObj = IMG_RESOURCE
renderObj {
file.import.data = file:current:uid
file.treatIdAsReference = 1
altText.data = file:current:title
stdWrap.typolink.parameter.data = file:current:link
file.maxW=1920
file.params=-rotate 0 -strip -quality 75
}
}
in the fluidtemplate I call it as follows:
<section class="sidebar" style="background-image: url({f:cObject(typoscriptObjectPath: 'lib.catImg')})">
if I follow the link the page doesn't load the image (in debug mode it gives an error: No Content Object definition found at TypoScript object path "lib.catImg"
)
but if I do a ctrl + F5 the page loads correctly ... anyone recognises what is going on (and how to correct it)
TYPO3 V12.4.24 - News 12.1.0 (I load the same way from table 'pages' the field 'media' without trouble.)
ADDED: I did not change the code in my question after I got the right indications, otherwise the question makes no sense anymore, apply what is suggested in the accepted answer to make this work
Maybe the ordering of the typoscript including is wrong? Maybe news is included before the lib.catImg
? If so the cache building reach the news displaying before the lib.catImg
is included so the lib.catImg
is not found?
I also think the typoscript is wrong. Instead of file:current:uid
I would use file:current:publicUrl
(also remove treatIdAsReference
). I would remove stdWrap.typolink
because you wouldn't want a link around your image url. Also altText
is not needed because you don't have an image tag. Also use maxItems = 1
because you don't want more than one here.