Empty cell Typo3 Fluid - typo3

Trying to set up a query for the "address list-Plugin" in Typo3.
So if my cell "Title" is written to there would be some information like "Prof.Dr." but if there's no Title on the Entry there should be "-"
Got no code at all at this point because its totally new to me but i assume it would like this a bit:
f:if condition{empty.cell} - or something. Never worked with it till yesterday and can't find any documentation that's helpful about my problem

An introduction to FLUID could be found here
A special hint for beginners:
If you want to know which FLUID variables are defined you can use of the f:debug Viewhelper:
<f:debug title="info at ...">{_all}</f:debug>
The exact syntax for your usage would be:
<f:if condition="{address.title}">
<f:then>{address.title}</f:then>
<f:else>-</f:else>
</f:if>

Related

TYPO3 10.4: tx_news content elements rendering error

I am updating TYPO3 from Version 8 to 9 and 10. Now there is one error, I am not able to find a solution.
In tx_news details view I am using custom fluid templates. In TYPO3 8 and 9 everything works fine. In TYPO3 10.4 I get an error when showing the detail page:
(1/1) #1381512761 TYPO3\CMS\Core\Type\Exception\InvalidEnumerationValueException
Invalid value "FILE" for enumeration "TYPO3\CMS\Core\DataHandling\TableColumnSubType"
If I remove this code for content elements in the fluid template, the page will be shown without errors:
<f:if condition="{newsItem.contentElements}">
<!-- content elements -->
<f:cObject typoscriptObjectPath="lib.tx_news.contentElementRendering">{newsItem.contentElementIdList}</f:cObject>
</f:if>
As I'm using content elements, I need this code.
You can see the error at the moment here:
https://asienhaus104.der-koenig.net/aktuelles/detail/spenden-fuer-die-suedostasien
I tried lots of variants to solve this, but still the error will be there when I insert the fluid output for content elements.
It seems you have a content element inside which is rendered in TypoScript with the FILE object (which was removed in v10). Take a look in your TypoScript (TypoScript object browser is best for this) and search for FILE objects (and replace them).
Here you can find the deprecation notice and a migration suggestion: https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.5/Deprecation-85970-FileContentObject.html

TYPO3 9.5 Introduction package

How can I get the language selection from the footer into the header area - with introduction-package in TYPO3?
The introduction-package (technically a "TYPO3 distribution") uses the extension bootstrap-package for the layout.
If you have not already you would want to define Fluid paths for overwriting certain templates: https://docs.typo3.org/p/bk2k/bootstrap-package/11.0/en-us/Configuration/TypoScript/Index.html#page-fluidtemplate.
This would add your path to the chain of Fluid directories with highest priority.
To move around the language menu you'll want to change where this partial in included (finding the partial is easy by searching for recognizable HTML-code like IDs):
Partials/Page/Navigation/Language.html
You can include it in your overwritten
Partials/Page/Navigation/Main.html like this:
<f:render partial="Navigation/Language" arguments="{_all}" />
The Partials/Page/Navigation/Main.html is just an example. You can put it where you want. But you have to make sure that the used variable languagenavigation is passed to your partial. That is done by the arguments="...". For the example given this will work because it is itself included from the main Layouts/Page/Default.html and gets also arguments="{_all}".
To learn where languagenavigation comes from have a look at Configuration/TypoScript/setup.typoscript. You'll see it being filled by a DataProcessor inside a 10 = FLUIDTEMPLATE block.
I hope that helps. Feel free to tell us how you fare :) And don't be shy to ask any further questions.

Fluid Viewhelper f:format.json returns htmlentities and more problems with curly braces in fluid

in TYPO3 8 LTS i try build a json output from news list. When using the viewhelper f:format.json in exact the same way as in the fluid manual:
{f:format.json(value: {foo: 'bar', bar: 'baz'})}
i get this:
{"foo":"bar","bar":"baz"}
this works:
{f:format.json(value: newsItem.datetime)->f:format.htmlentitiesDecode()}
but i need the date-object formatted in this way:
{newsItem.datetime->f:format.date(format: "%Y-%m-%d")}
and now i am looking for a possibility to match both in order to get this output:
{'date':'2018-03-16'}
I tried a many ways like this, but nothing works.
{f:format.json(value: {date:newsItem.datetime->f:format.date(format: "%Y-%m-%d")})->f:format.htmlentitiesDecode()}
any idea how to get it right?
Thanks
Peter
well Bernd showed me the way in his comment above - here is one of the solutions which i found with this little help of him:
{f:format.json(value: {date:'{newsItem.datetime->f:format.date(format: "%Y-%m-%d")}'})->f:format.htmlentitiesDecode()}
f:format.raw works much the same like f:format.htmlentitiesDecode; really important are the two '' around {newsItem.datetime->f:format.date(format: "%Y-%m-%d")}.
With the idea of format.raw i found an other solution too:
<f:format.raw value='{"date":"' />{newsItem.datetime->f:format.date(format: "%Y-%m-%d")}<f:format.raw value='"},' />
Looks quite a bit complicated but with
<f:format.raw value='{' />
<f:format.raw value='}' />
it is possible to use curly brackets in fluid templates.
Thanks!

TYPO3: category tree of tx-news, render sub-tree only if main is selected

I override Templates/Styles/TWB/Templates/Category/List.html to have the category menu behave exactly as the sidebar menu in the introduction package (submenus show only if main is selected).
If I add the static template "News Styles Twitter Bootstrap (news)" I'm almost there, it is not difficult to open the sub-categories only if the main category is selected (I need a massive amount of categories/sub-categories), but it should also be open when a sub is selected:
...
<f:if condition="{0:category.item.uid,1:category.item.uid} == {0:overwriteDemand.categories,1:category.children.{overwriteDemand.categories}.parent}">
<f:if condition="{category.children}">
<f:render section="categoryTree" arguments="{categories: category.children,overwriteDemand:overwriteDemand,class:''}" />
</f:if>
</f:if>
...
I do not know how to use {overwriteDemand.categories} as key to match the value ... can anybody point to the proper syntax
update: I tried to apply a custom ViewHelper as this post suggests, but using TYPO3 V7.6.16 got stuck with the error should be compatible with TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper:‌​:render(), so could not try working with the variable overwriteDemand.categories in another way ...
Dynamic access to variables in fluid is just possible since TYPO3 8. Check out the Whats New Slides here: https://typo3.org/download/release-notes/whats-new/ and search for "Dynamic variable name parts" in the PDF.
In TYPO3 7, the "vhs"-Extension provides a ViewHelper to do the same job but nesting a ViewHelper within an complex f:if-condition is even more difficult. If possible, try out TYPO3 8. If it's not possible you may write your own ViewHelper to solve this logical problem.

Link to file in Fluid – how to specify storage?

As far as I know, there's no such thing as an f:link.file or v:link.file viewhelper.
There used to be a solution using file.originalResource.publicUrl as the value to point the link to, as in
<f:link.page pageUid="{file.originalResource.publicUrl}" target="_blank">
Am I right that this is no longer necessary? I got this (using ext:mask):
<f:link.page pageUid="{file.identifier}" target="_blank">
returning the same value, while originalResource.publicUrl would not even show up in f:debug.
BUT in file.identifier the storage path, e.g. fileadmin, is not present. How do I add it to the viewhelper?
Or, what is the currently recommended solution for a link to a file in TYPO3 7.6?
Just use {file.name}. When absolute URL or some special configuration is needed use <f:link.typolink parameter="{file.publicUrl}">{file.name}</f:link.typolink>.
TYPO3 11 introduced a new ViewHelper for this
<f:link.file file="{file}" target="_blank">Download</f:link.file>
https://docs.typo3.org/other/typo3/view-helper-reference/11.5/en-us/typo3/fluid/latest/Link/File.html
For me, #minifranske’s solution worked only as a hint: I needed to use {file.originalResource.publicUrl} instead:
<f:link.typolink parameter="{file.originalResource.publicUrl}">{file.originalResource.title}</f:link.typolink>
also available:
{file.originalResource.name}
{file.originalResource.description}
{file.originalResource.alternative}
Nevertheless, if anybody knows a proper core solution which resembles that of the Rich Text Editor, I’d be happy to hear about it:
file link
page link
<f:uri.image image="{imageObject}" /> produces the path + filename for your FAL object.