Situation
sysext:filemetadata is activated; images (fal references) are deposited within page resources (pages.media).
2 options are currently known to me in conjunction to TYPO3 pages:
Using a custom FAL viewhelper
Using TypoScript (which is often illegible and not easy to maintain)
Question
What's actually (TYPO3 7.x and 8.x) a common/core-only solution to render such images within fluid with additional properties (metadata) like creator, copyright and so on?
I would go for next approach:
typoscript
page.10 = FLUIDTEMPLATE
page.10 {
dataProcessing {
10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
10 {
references.fieldName = media
}
}
...
}
fluid
<f:for each="{files}" as="file">
<div class="media">
<figure>
<f:media file="{file}" />
<figcaption>
{file.description}<br />
author: {file.properties.creator}<br />
copyright: {file.properties.copyright}
</figcaption>
</figure>
</div>
</f:for>
...
To find all possible sys_file_reference and sys_file_metadata properties just add <f:debug>{file.properties}</f:debug> inside the <f:for ...</f:for>.
Related
I want to override an extension's fluid template in Typo3 with my own template. My own template contains an if-condition. If not met, I want to include/render the extension's template (i.e. the overridden template) instead.
The actual case: I'm using the Typo3 News Extension which allows custom "template layouts". I want to add my custom template layout but also keep the News Extension's default template:
<!-- my_site_package/Resources/Private/Extensions/News/Templates/News/List.html -->
<f:if condition="{settings.templateLayout} == 2">
<f:then>
My specific list view for news entries
<ul>
<li>
...
</li>
</ul>
</f:then>
<f:else>
<!--
Include the original template here, e.g.
EXT:news/Resources/Private/Templates/Styles/Twb5/Templates/News/List.html
-->
</f:else>
</f:if>
How can I include / render the overridden template itself?
Fluid Is not able to Render the "Original Template" as there might be any number of TemplateRootpaths providing the Template. what you could do:
if the original Template is Part of an extension you controll, best to move the "Repeating" parts to an Partial. and let the Original Template use this partial as well.
if the original template is part of an extension you do not controll. (eg by a third party) you should copy the orignal template as partial in your Extension and then render this Partial. maybe ad a comment that this is an 1:1 copy of the original and shoud not be modified.
You can create another template layouts using page TSConfig, Define this TS in your root Page TSconfig (inside Resources) Tab.
plugin.tx_news {
templateLayouts {
1 = Homepage
2 = Specific list
}
}
then in your template you will get selected template value here in case 1 or 2.
You will find more help here.
https://docs.typo3.org/p/georgringer/news/main/en-us/Reference/TsConfig/General.html#confval-templateLayouts
I have a self written TYPO3 extension (I used ext:extension_builder to create it)
My top-level TypoScript looks like this:
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
format = html
file = EXT:cmsp/Resources/Private/Templates/User/Default.html
partialRootPaths {
10 = EXT:cmsp/Resources/Private/Partials/
}
layoutRootPaths {
10 = EXT:cmsp/Resources/Private/Layouts/
}
templateRootPaths
10 = EXT:cmsp/Resources/Private/Templates/
}
variables {
content_main < styles.content.get
content_main.select.where = colPos = 0
}
}
I used a simple Fluid Styled Content template:
<f:link.action controller="user" action="search" class="btn btn-secondary">action link</f:link.action>
The search action is registered in ext_localconf.php:
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'SimpleParser.Cmsp',
'Cmspfe',
[
'User' => 'list,search'
],
// non-cacheable actions
[
'User' => 'list,search'
]
);
I have also a template Search.html:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Search" />
<f:section name="content">
<h1>Search Template</h1>
<f:flashMessages />
<table class="tx_cmsp" >
<tr>
<th> </th>
<th> </th>
</tr>
</table>
<form action="SearchConfim.php">
Searchterm: <input type="text" name="sTerm"><br>
<input type="submit" value="Submit">
</form>
</f:section>
</html>
The problem is that I cannot create or follow a link in the website frontend from top-level Default.html (FLUIDTEMPLATE object) to Search.html (Extbase controller template):
<f:link.action controller="user" action="search" class="btn btn-secondary">action link</f:link.action>
I just stay on Default.html all the time, even when I click an action link of my controller. I can create external links with
<f:link.external ... ></f:link.external>
The external link is working but I cannot use a link to access Search.html.
Perhaps the problem is that I use a TypoScript which does not activate the controller (in a right way). But I'm happy if anyone can help me.
Your controller name is User with an uppercase U.
Use the same name in your f:link.action, if the controller is not being changed you can even remove this parameter.
It seems that Default.html is the name of the top-level rendering template in FLUIDTEMPLATE. So, I assume that <f:link.action ... tag is placed in that file - at least the currently generated link seems to confirm it and looks like the following:
index.php?id=1
&tx__%5Baction%5D=search
&tx__%5Bcontroller%5D=User
&cHash=dffabf13e973c371d14fb2e34b23d1a0
It uses tx__ as prefix which actually should be something like tx_cmsp_cmspfe (the combination of your extension name and the corresponding plugin name to be used).
Brief explanation
Default.html template is outside of the Extbase scope and thus does not know about the current extension, controller and plugin that shall be used
usually links appear in templates of the same extension (e.g. in Resources/Private/Templates/List.html)
otherwise according scope has to be defined explicitly (like shown below)
Solution for placing link to Extbase plugin in top-level rendering template
This example can be used outside the Extbase scope on Default.html template for the current page layout - however, it explicitly has to use the correct Extbase plugin scope:
<f:link.action
action="search"
controller="User"
pluginName="Cmspfe"
extensionName="Cmsp"
pageUid="4321"
class="btn btn-secondary">
action link
</f:link.action>
pageUid has to be adjusted and refers to the page the plugin is currently being used as content element
see https://fluidtypo3.org/viewhelpers/fluid/master/Link/ActionViewHelper.html as reference for links
see https://fluidtypo3.org/viewhelpers/fluid/master/FormViewHelper.html as reference for scoped <form> elements (which appeared in your code as well - pluginName, extensionName and pageUid are essential attributes in this scenario as well)
can someone help me adding a lib to the main section of the page via typoscript
TS:
[globalVar = TSFE:id = 314]
includeLibs.voucher = fileadmin/php/shop_init.php
lib.phpscript = USER
lib.phpscript.userFunc = voucher->init
[global]
Template:
<div class="main-section">
<f:render section="Main" />
<f:cObject typoscriptObjectPath="lib.phpscript" />
</div>
Now the content is showing after the Main section but i need it in the main section :/
What is the ts code for this??
THX in advance!
You have to add
<f:cObject typoscriptObjectPath="lib.phpscript" />
in a template between the tags
<f:section name="main"></f:section>
You can find the templates in the folder:
your_extension\Resources\Private\Templates\
I'm using Typo3 7.6.4 and I want to wrap an extension output with a div.
The extension is csv-table.
How can I do this with Typoscript?
Most plug-ins are defined as a USER or USER_INT objects. These have a property stdWrap See TypoScript Reference - USER(_INT)
I couldn't find the extension 'csv-table' for TYPO3 7, but let's assume that it's available in TypoScript as plugin.tx_csvtable_pi1 then you could use something like:
plugin.tx_csvtable_pi1.stdWrap.wrap = <div class="myCsvTable">|</div>
The best way is to use a fluid layout if you use EXT:fluid_styled_content
Resources/Private/Templates/CsvTable.html
<f:layout name="Default" />
<f:section name="Main">
my output
</f:section>
Resources/Private/Layouts/Default.html
<div class="my-element">
<f:render section="Main" />
</div>
TypoScript reference: FLUIDTEMPLATE
If you use the old css_styled_content you can use this
tt_content.my_ext = COA
tt_content.my_ext.stdWrap.wrap = <div>|</div>
I'm trying to access the settings of a Fluidtypo3 FCE element. My FCE is a news article that I want to include in another FCE, which is a slider. The slider only has one field and the configuration is the following:
<flux:field.relation
name="articles"
label="News-Beitrag"
multiple="true"
size="6"
table="tt_content"
condition="AND tt_content.pid = {record.pid} AND CType = 'fluidcontent_content' AND colPos = 1 AND sys_language_uid = {record.sys_language_uid}"
minItems="1"
maxItems="10"
renderMode="default"
/>
This configuration works, I can select all my news FCE's as a relation. The field articles saves the uid's of all referenced FCE's. Now I am trying to use these uid's to receive the content. Right now my code is the following:
<f:section name="Main">
<f:if condition="{articles}">
{v:iterator.explode(content: '{articles}', glue: ",", as: 'articles')}
{v:content.get(contentUids: "{articles}", render: 0) -> v:variable.set(name: 'slides')}
<f:for each="{slides}" as="element">
</f:for>
</f:if>
</f:section>
The <v:content.get> ViewHelper gets the tt_content record as it is recorded in the database. The flux settings are stored in XML-Format in the field pi_flexform. I am trying to access those specific flux settings one by one and not just the whole pi_flexform field in xml format.
I've looked for ViewHelpers that can convert XML to an Array and tried many other things, but nothing worked for me. I am grateful for any ideas how to solve this problem.
<flux:form.data> is the Viewhelper you seek. You can use it like this:
<f:for each="{slides}" as="element">
<flux:form.data table="tt_content" field="pi_flexform" record="{element}" as="flexformData">
<!-- Do stuff with flexformData -->
</flux:form.data>
</f:for>