in the following script:
tt_content.myFCE {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = image
as = files
}
20 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
20 {
references.fieldname = assets
as = myFiles
}
}
}
the first part (index 10) works but the second (index 20) doesnt. I get an empty array. It seems that the FilesProcessor is not able to access the images which are stored in assets.
Is there a possibility to fetch the assets from the field assets?
Thanks!
Bernd Wilke wrote it in his comment: there is a typo in fieldname - it should be fieldName ... i was totaly blind, didn`t see it until his comment. What a shame ... :-) After correcting the typo all works exactly as expected.
Related
I want to change the Layout of my Headers in TYPO3. There is a post about this but this but I cant get it to work and that post is 2 years old. With TYPO3 most stuff is outdated quite quickly. This is the post.
Additionally I looked at this article. I know it is in German, maybe it helps anyways.
So I copied the Header.html from the TYPO3 system files, put it in a directory under fileadmin and tried to link to that directory.
fileadmin/.../Partials/Header/Header.html
In the Template setup i added the partialRootPath.
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10.file = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/index.html
10.partialRootPath {
20 = fileadmin/Resources/Private/Partials
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
In Header.html I created an additional case to check if it was working.
<f:case value="7">
<p class="{positionClass}">
<f:link.typolink parameter="{link}">{header}</f:link.typolink>
</p>
</f:case>
I then added that new case in the Page Resources to the TSConfig.
TCEFORM.tt_content.header_layout {
addItems.7 = Name1
}
Changing the content of the Header.html file in the TYPO3 system files works the way I expected it to, so I am quite sure that I understand the basic functionality. The TSConfig part works as well, because I can select "Name1" in the Header Layout Type field.
But no matter what part in the fileadmin Header.html version I change, nothing happens. I checked the path to that Partials folder and the spelling of everything a million times, so I do not think that is the issue either.
Of course I could just change the system file Header.html but that seems wrong on a lot of levels.
Thank you for any help.
Don't mix different usages of fluid!
You want to change the header partial of your content elements.
But you add the new partial to the fluid of page rendering.
if you use FSC (Fluid Styled Content) your additional partial path should go here:
lib.contentElement {
partialRootPaths {
10 = fileadmin/Resources/Private/Partials
}
}
breaking change: lib.contentElementinstead of lib.fluidContent
Additional advices:
be carefull with the names: aside from partialRootPaths there sometimes exist partialRootPath (without s in the end), which is not an object array. That enables you to set only one path (not the usual path list with priority) and which has priority over settings in partialRootPaths if both exist.
separate the different fluid usages!
Give them different paths. There are multiple ways. I prefer:
each extension gets it's own three folders in a folder named for the extension.
And also separate the page rendering and CEs (Content Elements). Your own CEs might be considered as part of the extension 'FSC'.
use a site extension.
All configuration goes into that extension: typoscript, templates, viewhelpers, TCA, ...
That is the basic configuration for that site, but also the additional configuration/ adaption for the used extensions.
May this code will help you!!
page = PAGE
page {
shortcutIcon = fileadmin/sitedesign/Resources/Private/Templates/Vave/img/Favicon.ico
10 = FLUIDTEMPLATE
10 {
templateName = TEXT
templateName {
cObject = TEXT
cObject {
data = levelfield:-2,backend_layout_next_level,slide
override.field = backend_layout
required = 1
case = uppercamelcase
split {
token = pagets__
cObjNum = 1
1.current = 1
}
}
ifEmpty = Innenseite
}
#templateName=TEXT
# templateName.value=index
layoutRootPaths {
20 = your layoutRootPaths
}
partialRootPaths {
20 = your partialRootPath
}
templateRootPaths {
20 = your templateRootPath
}
}
includeCSS {
contactFile1 = fileadmin/sitedesign/Resources/Private/Templates/Vave/Contact/css/Contact.css
}
}
Make sure header included properly in main template
tldr: How do I render a TypoScript COA Object with a GIFBUILDER image from inside a CommandController?
I'm currently developing an eCommerce platform for which I need to periodically import an excel file that holds the product catalog. After a product is created from a row of data in the excel file, a directory is searched for product images related to that item, and they are linked as FileReferences to the product. I've written an ImportCommandController that takes care of that.
This all works like a charm, with the only glaring problem being the performance of the image manipulation. The first call to a product list pages takes a good 30 seconds, the first request of a single view. I periodically need to recreate the whole catalog from scratch, and the source product images are huge files, I have no influence on that.
The product images of that catalog are being generated by a TypoScript that takes care of fitting these images inside a square white background, returning the IMG_RESOURCE url. I call that TypoScript from inside a Fluid template with the cObject ViewHelper.
I've been trying to call this bit of TypoScript from the ImportCommandController->importAction, so that the import cronjob would take care of creating these scaled images beforehand, with the same filename hash, so they're already processed when they're called by the single view. But I can't manage to do that.
The TypoScript in question ist this:
plugin.tx_productfinder_products {
// Productfinder-Produktbilder
// Bilder quadratisch auf weissen Hintergrund einpassen
productimage = COA
productimage {
// Daten der FileReference im Regsiter ablegen
10 = FILES
10 {
references.data = current
renderObj = COA
renderObj {
10 = LOAD_REGISTER
10 {
param = TEXT
param.data = file:current.uid
}
}
}
20 = IMG_RESOURCE
20 {
file = GIFBUILDER
file {
XY = 960,960
format = jpg
quality = 95
backColor = #ffffff
20 = IMAGE
20 {
offset = 960-[20.w]/2,960-[20.h]/2
file {
import.data = current
treatIdAsReference = 1
maxW = 960
maxH = 960
}
}
// // Text aus Daten der FileReference als Wasserzeichen ins Bild rendern
// 30 = TEXT
// 30 {
// //text.data = register:param
// text.data = current
// fontColor= #dddddd
// fontSize = 12
// offset = 20,[20.h]-20
// align = left
// antiAlias = 1
// }
}
}
}
}
And I call these from inside the Fluid template like so:
<img class="img-responsive" src="{f:cObject(typoscriptObjectPath:'plugin.tx_productfinder_products.productpreviewimage', data:'{image.uid}')}">
What have I tried so far? Pretty much everything.
I've first tried to call the ContentObjectRenderer directly,
/** #var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$contentObject->setCurrentVal($image->getUid());
$content = $contentObject->cObjGetSingle($this->settings['productimagetest'], $this->settings['productimagetest.']);
resulting in these weird errors.
Oops, an error occurred: PHP Warning: imagejpeg(typo3temp/GB/csm_8000424600_cbbd127be3_9cb1d3c8cc.jpg): failed to open stream: No such file or directory in /html/typo3/typo3_src-7.6.16/typo3/sysext/core/Classes/Imaging/GraphicalFunctions.php line 2912
It seems that the TYPO3 Configuration regarding the Grapics Processing isn't initialized in the same way as it is for the Frontend.
Next, I tried instanciate a StandaloneFluidView to render the whole SingleItem template per item, but I cant figure that out because the Request and Context are missing and so the partials being referenced in the template aren't being rendered.
Then I tired to just create the FrontendUrls per single item and request them from the CommandController,
/** #var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj */
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$test = $contentObject->typolink_URL(array(
'parameter' => 671,
'additionalParams' =>
'&tx_productfinder_products[product]='.$product->getUid().
'&tx_productfinder_products[action]=show'.
'&tx_productfinder_products[controller]=Product',
'returnLast' => 'url'
));
$this->outputLine(print_r($test,true));
but the URLs generated in this way are missing the cHash.
Can anybody offer help or a different approach to this?
Since these images are generated just once for the frontend output and are then available anyway, I don't see the advantage of generating them beforehand. The white square could be easily generated with CSS, so to me this does not even look like a use case for the GIFBUILDER.
That being said there's still something you could do: Since you are in the PHP context already, why don't you instanciate the GIFBUILDER directly or use even pure IM/GM commands instead of going for an IMG_RESOURCE which is actually meant to be output in the frontend?
I know this is an old question, but I had the same issue and had to invest some time to debug it, so maybe this this answer is useful for someone else in the future.
The CLI uses a different working directory than the frontend, therefore the relative path to typo3temp/ directory used in the GifBuilder class cannot be resolved, which results in the above mentioned warning.
To fix the relative path resolution, you have to change your working directory to the frontend one, this can be achieved by:
class AcmeCommand extends Command
{
protected static $cwdBackup;
protected function execute(InputInterface $input, OutputInterface $output)
{
if (Environment::isCli()) {
static::$cwdBackup = getcwd();
chdir(Environment::getPublicPath());
}
//
if (Environment::isCli()) {
chdir(static::$cwdBackup);
}
}
}
It might be a simple solution to that but I am not able to figure it out.
I implement a typo3 6.2.12 website using the bootstrap_package extension. There I have a page with child pages within the page tree. On each child page a comment function should be attached at the end of the main page content. For the comment functionality I use the pw_comments extension, as it is very flexible.
The pw_comments manual shows a possible the integration as follows:
lib.content = COA
lib.content {
10 < styles.content.get
# List comments
20 < lib.pwCommentsIndex
# Write new comment
30 < lib.pwCommentsNew
}
Actually very simple and straightforward.
The bootstrap package extension handles the content as follows (inside base.ts):
lib.dynamicContent = COA
lib.dynamicContent {
5 = LOAD_REGISTER
5 {
colPos.cObject = TEXT
colPos.cObject {
field = colPos
ifEmpty.cObject = TEXT
ifEmpty.cObject {
value.current = 1
ifEmpty = 0
}
}
pageUid.cObject = TEXT
pageUid.cObject {
field = pageUid
ifEmpty.data = TSFE:id
}
}
20 < styles.content.get
20.select.where = colPos={register:colPos}
20.select.where.insertData = 1
20.select.pidInList.data = register:pageUid
90 = RESTORE_REGISTER
}
lib.dynamicContentSlide =< lib.dynamicContent
lib.dynamicContentSlide.20.slide = -1
And at that point I have no clue how to integrate pw_comments. In the setup of the plugin I tried this:
[PIDupinRootline = 54]
lib.dynamicContent = COA
lib.dynamicContent {
# List comments
30 < lib.pwCommentsIndex
# Write new comment
31 < lib.pwCommentsNew
}
[end]
The goal of the above is: Attach pw_comments to the main column output to each child page of parent page with uid 54.
Actually it is working but due to the inheritance with lib.dynamicContentSlide =< lib.dynamicContent the comments get also attached each of the 3 footer columns which is not desired behavior.
I could use the plugin extension which is available for pw_comments but that would mean that the editor has always to add that plugin to new child pages when creating them.
I could "hack" the fluid content template files and add a <f:cObject /> tag and call the plugin lib, but I think that solution is odd and .. well .. a hack.
So is there any way how I could attach that plugin to these child pages in a typo script way? I guess it is just a lack of syntax knowledge and yes, typo3 is not my every day job.
Hope anybody can give me a hand on this issue. Thanks so much in advance!
You simple need to replace the reference by a real copy before you add your TypoScript.
lib.dynamicContentSlide < lib.dynamicContent
# your TS goes here
Just repeat all lines with an reference to lib.dynamicContent with a copy operator instead, before you add your modifications to the actual content definition.
Ok, the headline is bit confusing, but i didnt know, how to describe my problem in a short version. Here we go: I get a list of image-urls from the resources of one page, it works like this:
lib.slider = FILES
lib.slider {
references {
data = levelmedia:-1, slide
}
renderObj = TEXT
renderObj {
data = file:current:publicUrl
wrap = {image :'|'}
}
}
Now i want to make an image-container from each of the images. I'm not very good in typoscript so i have no idea, how to do that. I had the idea of making an array out of it and using the f:for-Viewhelper but I dont know how to get an array from this or how to access the images from html.
As an alternative to your own findings, you can modify the renderObj to be an IMAGE cObject, like the following - that way you can define dimensions of your images as well.
lib.slider = FILES
lib.slider {
...
renderObj = IMAGE
renderObj {
file {
import.data = file:current:originalUid // file:current:uid
maxW = 150
}
}
}
See the FILES documentation and IMAGE documentation for further examples.
Ok, I found a solution myself, ich just changed the wrapper to <img src="|" /> and got what i wanted
In tt_news, how can I display a default image when there are no images associated with the news? I tried
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject = IMAGE
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject {
wrap =
file = fileadmin/images/image.jpg
}
but it doesn't display the image.
It should work with this:
plugin.tt_news.displaySingle.image.noImage_stdWrap {
cObject = IMAGE
cObject {
file = fileadmin/news-image-default.jpg
wrap =
}
}
i guess there is a dot between "displaySingle" and "image" missing?
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject = IMAGE
plugin.tt_news.displaySingle.image.noImage_stdWrap.cObject {
file = fileadmin/images/image.jpg
}
This code works for me. Path to file must be correct and image file must exists otherwise Typo don't display anything.
plugin.tt_news.displaySingle.image.noImage_stdWrap {
cObject = IMAGE
cObject {
file = fileadmin/tt_news/default_image.jpg
wrap = |
}
}