I need to render a partial from my Main Template (SitePackage) within a MASK content element. The partial is located in the folder Resources/Private/Partials and the fluid code of my content element is located in Resources/Private/Extensions/Mask/Frontend/Templates.
This is my (testing) partial (Test.html):
<div class="header">
<h3>Dies ist ein Partial</h3>
</div>
In the MASK content element I try to render it with <f:render partial="Test"/>, but it doesen't work, the page is showing the following error message:
The Fluid template files "[...]/Resources/Private/Extensions/Mask/Frontend/Partials/Test.html", "[...]/Resources/Private/Extensions/Mask/Frontend/Partials/Test" could not be loaded.).
Is there a way to render a partial from outside my Extension folder?
Thanks in advance for any help!
Like for any FLUID templating you can add further paths to select layout, template or partial.
Just add the further paths with new numbers to the list of these paths.
In mask you define the paths like:
module.tx_mask.view {
layoutRootPaths.30 = EXT:your_site_extension/Resources/Private/Layouts
partialRootPaths.30 = EXT:your_site_extension/Resources/Private/Partials
templateRootPaths.30 = EXT:your_site_extension/Resources/Private/Templates
}
plugin.tx_mask.view {
layoutRootPaths.30 = EXT:your_site_extension/Resources/Private/Layouts
partialRootPaths.30 = EXT:your_site_extension/Resources/Private/Partials
templateRootPaths.30 = EXT:your_site_extension/Resources/Private/Templates
}
Mind the plural -s in "layoutRootPaths", "templateRootPaths" & "partialRootPaths"! > TYPO3 Docs - FLUIDTEMPLATE
But be careful if you mix different templating sets like page-templates, mask-/CE-templates, news-templates, ....
you might get naming conflicts!!
Related
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 render a section in a partial from another extension.
My setup is TYPO3 7.6.14 with fluid powered TYPO3 extensions including VHS.
As far as i know it is not possible with the fluid ViewHelper f:render. Here you only have the arguments "partial" and "section".
I found one solution using the VHS ViewHelper v:render.template.
The solution is explained here: https://www.wapplersystems.de/blog/typo3-fluid-render-partial-from-another-extension/
But with this ViewHelper I can only set the path to the partial, but not to the section.
Fluid supports a lookup chain for partials, templates and layouts. You can specify multiple directories in your extension and fluid will look in all of them (beginning at the highest index) until it finds a matching partial file.
plugin.tx_myextension.view {
partialRootPaths {
10 = EXT:my_extension/Resources/Private/Partials
20 = EXT:another_extension/Resources/Private/Partials
}
}
With this configuration fluid will look for every partial in your extension at another_extension/Resources/Private/Partials first and render it from there if it is present.
I need the teaser as pure plain text , without any links or text formatting in the Latest view, the possibility . Is it provided for a corresponding ViewHelper or a different approach ?
HTML entities , it should not be served as & for & for example.
Use <f:format.stripTags> Viewhelper.
To ensure all html entities are decoded use <f:format.htmlentitiesDecode>
So you can use:
<f:format.stripTags>
<f:format.htmlentitiesDecode>
{newsTeaserVar}
</f:format.htmlentitiesDecode>
</f:format.stripTags>
The news list is rendered using a partial for each item (Resources/Private/Partials/List/Item.html). In that, you can see the line used for rendering the teaser:
{newsItem.teaser -> f:format.crop(maxCharacters: '{settings.cropMaxCharacters}', respectWordBoundaries:'1') -> f:format.html()}
If you remove the last view helper f:format.html(), then it won’t be converted to HTML. If you replace it with f:format.raw() (in case you have HTML in the teaser), then the HTML will be output as is, w/o converting < to < and > to > etc.
When overriding the partials, you should not directly modify the extension, but do it in an upgrade-safe way. For that, put them in your site extension or into fileadmin/ and add that partials path to the TS config:
plugin.tx_productview {
view {
partialRootPaths.1 = [path to partials folder]
}
}
For news, there is also a special mechanism: you can set a constant
plugin.tx_news.view.partialRootPath = […]
to the path.
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.
TYPO3 adds these links at the start of almost every element:
<a id="c1427"></a>
where number is, I guess, UID of the element.
How TYPO3 render this link and is it possible to disable it for a specific FCE?
It depends on your TYPO3 Version. In 4.5 it is defined via:
tt_content.stdWrap.innerWrap.cObject.default.10.value = <div id="c{field:uid}"
If you use the TS-Objectbrowser, you should find it somewhere in tt_content.stdWrap.*
Depending on the rendering you are using, you could be able to add an if statement like:
tt_content.stdWrap.innerWrap.cObject.default.10 {
# check the uid of the content element which is rendered
if.isInList.field = uid
# do not render if content element uid is 1,2 or 44
if.value = 1,2,44
}
For sure, it depends on your configuration, so you cannot copy & paste. And i did not test this code! But it should show the way to go:)
I think your problem is in tt_content.stdWrap.prepend that is different for any languages different from default language.
Try to put this typoscript in your template:
tt_content.stdWrap.prepend >
tt_content.stdWrap.wrap = <div class="content-element">|</div>