TYPO3 - How to check if a news article has a certain parent category with fluid - typo3

How can I check that a news article has a certain parent category in m'y Fluid template?

Maybe this can help :
<f:for each="{newsItem.categories}" as="category">
<f:if condition="{category.parent.uid} == theCatIdYouAreSearchingFor">
do your stuff here...
</f:if>
</f:for>

Related

TYPO3 10.4: Menu of subpages with image

I would like to expand the content element "menu of subpages" with images from page resources.
In TYPO3 8.7 the following code did everything i needed:
<f:if condition="{menu}">
<ul class="pagemenu-img">
<f:for each="{menu}" as="page">
<li>
<a href="{page.link}"{f:if(condition: page.target, then: ' target="{page.target}"')} title="{page.title}">
<f:image src="fileadmin/{page.files.0.originalFile.identifier}" />
<span>{page.title}</span>
</a>
</li>
</f:for>
</ul>
</f:if>
With TYPO3 10.4 this isn't working anymore.
Is there another way? Preferably without using VHS.
It's still working.
I have tested your HTML-Template and the result is as expected:
Your problems seem to be something other...
Maybe there were some pages which didn't have any images with them...
You should therefore check if there is an image present:
[and get rid of the hardcoded fileadmin/ link there by< just using {page.files.0.originalFile}]
<f:if condition="{menu}">
<ul class="pagemenu-img">
<f:for each="{menu}" as="page">
<li>
<a href="{page.link}"{f:if(condition: page.target, then: ' target="{page.target}"')} title="{page.title}">
<f:if condition="{page.files.0}">
<f:image image="{page.files.0.originalFile}" />
</f:if>
<span>{page.title}</span>
</a>
</li>
</f:for>
</ul>
</f:if>

Set Category title as header in list view (TYPO3 tx_news)

I want to add the category title to the list view element, that the category menu sends you to. I'm just not figuring it out...
Here is my code in the fluid template:
Templates/News/List.html
<div class="news-list-view">
<f:if condition="{categories.0.headline}">
<f:then>
<h1>{categories.0.headline}</h1>
</f:then>
<f:else>
<h1>News Category</h1>
</f:else>
</f:if>
there is no field headline in a category. Use title which should work out well.
You can do like this.
<f:if condition="{news.0.categories}">
<f:then>
<f:for each="{news.0.categories}" as="Category">
<h1>{Category.title}</h1>
</f:for>
</f:then>
<f:else>
<h1>News Category</h1>
</f:else>
</f:if>

FAL file title won't show in front-end with file collection "folder from Storage"

.
Hello
it's hard to explain ...
If you're using TYPO3 7.6 (w. fluid styled content) with the module "file links", you can upload single files, but you can also work with the "file collection" to organize your downloads in a sys-folder.
There're three different types of "file collections". 1. Static selection of files and 2. Folder from Storrage and 3. Select by category.
Now you've upload and edit your FAL-files (metadata, s. image below) with a new title and description. These fields e.g. {file.title} will show with fluid_styled_content (Uploads.html), if you're using a single download or a file collection static selection of files, but not, if you're using Folder from storrage! The title won't show, you only see the {file.name} ..?
I'm using the standard Uploads.htmlform FSC with an extra condition.
Test <f:debug>{file.title}</f:debug>, see below. There's no Title from files via "folder from storrage".
...
<f:if condition="{file.title}">
<f:then>
{file.title}
</f:then>
<f:else>
{file.name}
</f:else>
</f:if>
...
Is it a bug or a feature for TYPO3 8?
I hope my pictures can explain this behavior better.
There was a TYPO3 Core Bug, but now it's fixed (TYPO3 7.6.15) - update Core and Fluid Styled Content-Template Uploads.html
Line 26
<a href="{file.publicUrl}"{f:if(condition:data.target,then:' target="{data.target}"')}>
<span class="ce-uploads-fileName">
<f:if condition="{file.properties.title}">
<f:then>
{file.properties.title}
</f:then>
<f:else>
{file.name}
</f:else>
</f:if>
</span>
</a>
Thanks to the TYPO3 Core Development Team! See revision.

Backend Preview - get Image or IRRE data in Fluidtemplate

I use a Fluid Template for the backend: mod.web_layout.tt_content.preview
Is it possible to get images from FAL or data from an IRRE element in this template?
For the frontend there is the TYPO3\CMS\Frontend\DataProcessing\FilesProcessor for example. Could that also be used in backend?
You would need a custom VH (IMO VHS also provides those) which gets you the data. It is not possible by default with the core.
I ended up lately to use the hook PageLayoutViewDrawItem in TYPO3\CMS\Backend\View\PageLayoutView for doing that. That was the easiest way.
As Georg Ringer has already mentioned, you can render preview images in Fluid Preview Templates with the VHS ViewHelper v:resource.record.fal
https://viewhelpers.fluidtypo3.org/fluidtypo3/vhs/5.0.1/Resource/Record/Fal.html
As record I must pass the argument _all because I have no other record available.
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:if condition="{assets}">
<v:content.resources.fal field="assets" as="images" record="{_all}">
<f:for each="{images}" as="image">
<f:if condition="{image}">
<f:image src="{image.id}" treatIdAsReference="1" width="100"/>
</f:if>
</f:for>
</v:content.resources.fal>
</f:if>
</html>

Prevent Typo3 broken image url error

In my Typo3 extension I'm showing a lot of images with fluid, an list view of products. Only if for some reason one image is missing on my server, Typo3 generates an full screen error so the complete website is then not working.
I my opinion there are three way to prevent it:
1) Configure Typo3 so it is ignoring broken image url's. Does anyone know if this is possible?
2) Let Fluid check if the image exists before it is generated. Don't know if this is possible?
3) Use the controller to check if the image exists before it is send to the frond-end. Only due to the manny images it uses a lot of processing.
I prefer the use of the media exists viewhelper from the VHS Viewhelper package. After installing and activating the extension it should look like this screenshot in your TYPO3 extension manager.
This example iterates through a array of products, that have a public picture property holding the filename of it's picture.
{namespace v=FluidTYPO3\Vhs\ViewHelpers}
<f:for each="{products}" as="product">
<v:media.exists file="fileadmin/products/{product.picture}">
<f:then>
<f:image src="fileadmin/products/{product.picture}" />
</f:then>
<f:else>
<f:image src="fileadmin/noImageFound.jpg" />
</f:else>
</v:media.exists>
</f:for>