I would like to copy the values from a cObject data attribute in typoscript:
<f:cObject typoscriptObjectPath="lib.datei" data="{link}" />
in ts I can get it with:
lib.datei = TEXT
lib.datei.current = 1
it works, but I can not copy or reference it to another ts-object:
lib.test = TEXT
lib.test < lib.datei
if the value of lib.datei is a plain Text it works...
where am I wrong...??
I think you missed the context. the Context a typoscript object is valid and has a specific value.
if you call some typoscript rom a fluid viewhelper that specific object has a value. Inside that object you also can access global values.
But you have no access from another (temporarily) object called in another fluid-viewhelper call.
Neither can you access in your page rendering process on that specific value as that object has no input in that context.
Related
I have a component that uses two different resources in its HTL/Sightly template.
Is there a way to pass a parameter, to the say in my example the eventResource template, so that I can depending on this passed paramter change a css class on it?
<ul data-sly-list.teasers="${model.resourceList}" class="teaser-list-alternating c-list--reset">
<sly data-sly-test="${teasers.eventTeaser}"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser'}"></sly>
<li data-sly-test="${teasers.contentTeaser}" class="l-stack l-stack--horse"
data-component-hook-content-hub="teaser"
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/contentHubTeaser'}"></li>
</ul>
I tried using data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='blabla'} to no availability.
#RequestAttribute(name = "contentHub")
private String contentHub;
The requestAttribute contentHub in the eventTeaser model is alway null and I am not sure how to get the selectors value in the eventTeaser template.
I can do it using TypeScript on the front end part but it is not very clean.
I was able to solve it using the selectors indeed and reading the selector value directly from the other sightly template. Here is the documentation I refered to:
data-sly-resource="${teasers.resource # resourceType='xxx/components/content/eventTeaser', requestAttributes=model.config, selectors='inContentHub'}
In the eventTeaser template I then used the following:
data-sly-set.inContentHub="${'inContentHub' == request.requestPathInfo.selectorString}
and depending on the value of the inContentHub variable I was able to change the css class which was my ultimate goal.
I have my package from sitepackagebuilder (v9.5.14). I no good at Typoscript. I am using the optional menu navigation file MainBefore.html (my desired file) from bootstrap_package which I put in my stpkg extension because this file is globally available in the FE alongside main menu. I try to explain my doubt in the two following examples.
First one is clear to me. usually I do things like this, (My only known typoscript way to access and render things).
Example 1:
In typoscript
lib.stdContent = FLUIDTEMPLATE
lib.stdContent {
file = EXT:sitepackagebuilder/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
In Data.html
<h4>Hello TYPO3</h4>
<h3 hidden>{mylabel}</h3>
MainBefore.html
....
<div class="from-data-file"><f:cObject typoscriptObjectPath="lib.stdContent" /></div>
....
The above example will work.
Example 2:
But this following example is my doubt.
page.10 = FLUIDTEMPLATE
page.10.variables.userInfoForChat = COA_INT
page.10.variables.userInfoForChat {
10 = FLUIDTEMPLATE
10 {
file = EXT:company/Resources/Private/Partials/Page/DropIn/Navigation/Data.html
variables {
mylabel = TEXT
mylabel.value = Label coming from TypoScript!
}
}
}
How can I access variables in Data.html and render content in MainBefore.html like example 1? Correct me If I am wrong
Both files are in same location.
First: you are doing very complicated things. normaly stacking templates inside each other is not necessary. so the main question would be: What do you intend to do?
Then we can find a simple way to do it.
I try to identify your intention:
you have a main template (main = main for this example, otherwise it is just a small part of the general page rendering) where you want to have a variable, which is filled from another template, where some variable is inserted.
Some information is missing as these would not be necessary when all values are static like in your example.
There must be something non static as you use a uncached COA_INT and the name userInfoForChat hints to something user specific, which of course is not cachable.
My question is: why do you put a complete fluid templating in the variable, when it should be enough to have only some uncached values in it and stay with just one set of fluid template. (That set already could consists of template, layout and a lot of partials)
I want to pass a value from my fluid code to typoscript. I have two variable (one is int, the other is some text) and I want to use those values in typoscript. Is that possible and if it is possible how?
I want to use the values to create opengraph tags in head of HTML.
Here's my TypoScript
lib.getuserItems = TEXT
lib.getuserItems.wrap = |
page.meta {
og:description < lib.getuserItems
og:description.attribute = property
og:locale = de_DE
og:locale.attribute = property
}
and here's my Fluid
<f:cObject typoscriptObjectPath="lib.getuserItems" data="{article.description}" />
Your problem will not be the parameter transfer.
If you use <f:cObject> in fluid you can compute something with typoscript which is returned and can be used to render the fluid template.
You want some data from your fluid-template transferred to the page configuration (page.meta....) which is not possible in this way.
If you want to set those meta tag data you can use viewhelper in fluid, but that must be PHP viewhelper, that can access page configuration and set these data.
Be aware that TYPO3 9LTS has introduced an API for metatags
In the T3-Backend the file metadata can be edited in two places, within the form of the original file and in the form where the file is referenced. Edits in the second place overrule the data in the first place.
How to access the merged meta-data?
How to access the other two forms?
You can use f:image view helper in fluid:
https://docs.typo3.org/typo3cms/ExtbaseGuide/Fluid/ViewHelper/Image.html
If meta data is overwritten in reference this data will use with a fallback to default meta date set in module "Filelist".
Found this: How can I extract metadata properties from images with FAL and fluid?
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>.
This answer is based on current TYPO3 8.7.
The tables are explained here. sys_file_metadata hold the meta data of the original file. sys_file_reference overwrites this meta data from the point of referencing, if the very field is set in sys_file_reference.
If you get a Reference of the class TYPO3\CMS\Extbase\Domain\Model\FileReference you find the data in question under the property originalResource.
Despite its prefix original it does not only give access to the data from the table sys_file_metadata but also to the the table sys_file_reference and to the merged data.
If we name the reference as reference, then the paths are as follows for the title field:
Original files metadata (sys_file_metadata):
reference.originalResource.originalFile. metaDataProperties.title
Reference overlay (sys_file_reference):
reference.originalResource.propertiesOfFileReference.title
Merged data:
reference.originalResource.mergedProperties.title
also just:
reference.originalResource.title
Especially the wording of the last option is very counter-intuitive for a merged property. It would be more clean to drop the prefix original.
The access to other fields like alternative or description has analogous paths.
I get the following error message #1237900529: The argument "each" was registered with type "array", but is of type "string" in view helper "TYPO3\CMS\Fluid\ViewHelpers\ForViewHelper" while trying to iterate through the rows of my data using the following FLUIDTEMPLATE (FT) iteration:
<h2>Sources</h2>
<f:for each="{content_source}" as="source">
<p>{source.header}</p>
</f:for>
<h2>Contact</h2>
<f:for each="{content_contact}" as="contact">
<p>{contact.header}</p>
</f:for>
I'm running Typo3 6.2.14 and would like to parse this HTML to match with BootStrap's architecture in my custom built template. I don't have much knowledge on Typoscript & FT; it is however preferable for me to use FT over TypoScript to make conditions for html parsing. What should I adjust if I have the following TypoScript:
10 = FLUIDTEMPLATE
10{
file= fileadmin/Templates/index.html
layoutRootPath = fileadmin/Templates/layouts/
partialRootPath = fileadmin/Templates/partials/
variables {
content_source < styles.content.get
content_source.select.where = colPos=3
content_contact < styles.content.get
content_contact.select.where = colPos=4
}
}
For posterity, since this question is old and likely resolved already:
When you consume a variable from TypoScript this way, you get strings of rendered content - not an array of content records or an array of rendered content HTML strings. So the error is correct.
There are two main roads one would normally take to style the HTML output of the content you render, depending on the type of content element:
Change the TS wrapping etc. (if you use css_styled_content) or override the templates you want to change (if you use fluid_styled_content).
Override the templates you want to change, for all content types and plugins which use either FLUIDTEMPLATE TS object or Extbase MVC.
Lastly, there are third party ViewHelpers you can use in Fluid to fetch raw content records and render them as well - which will allow you to apply things like wrapping to content elements as part of the Fluid template. See https://fluidtypo3.org/viewhelpers/vhs/master/Content/GetViewHelper.html and v:content.render counterpart.