Add a link to extension resource in TYPO3? - typo3

I want to add link tags to the head so I can preload some font files in my site package.
I have tried using headerData but how can I get file path to EXT:my_site/Resources?

For any field in TypoScript that uses the getText data type, you can use path: for that. For example:
page.headerData.123 = TEXT
page.headerData.123.data = path:EXT:extension/Resources/Public/path/to/file
page.headerData.123.wrap = <tag property="|">
See https://docs.typo3.org/m/typo3/reference-typoscript/10.4/en-us/DataTypes/#path for more information.

Related

Add a static template to my typo3 extension

I have created an extension with sitepackagebuilder.com and the idea is just to write some static html.
I know that when you have a controller you can call the templates by following the convention names. But what if you don't have a controller? What I need, at least for now, is just to install the extension, add the plugin into a page and get some static content in that page.
I can imagine that this is set in a typoscript file but I'm quite noob with all the typoscript thing.
I'm getting this error:
'No Content Object definition found at TypoScript object path "tt_content.list.20.heboorganigram_organigram"'
Until I define that object in my typoscript file. I have tried this.
tt_content.list.20.heboorganigram_organigram = PAGE
tt_content.list.20.heboorganigram_organigram.10 = TEMPLATE //(or FLUIDTEMPLATE same result)
tt_content.list.20.heboorganigram_organigram.10.template = FILE
tt_content.list.20.heboorganigram_organigram.10.template.file = fileadmin/Organigram.html
And then I don't get an error but I also don't get the content from my Organigram.html, this is just trying stuffs, I actually don't know if this is what I need to do.
Before creating new Content Elements you first have to create the Page Template, for that have a look at the sitepackage tutorial https://docs.typo3.org/m/typo3/tutorial-sitepackage/master/en-us/FluidTemplates/Index.html
If you already got the page template, have a look at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html
Provided you already did the steps above, for getting the frontend output you are interested in the step Configure the frontend rendering
So the TypoScript should look something like this:
lib.contentElement {
templateRootPaths.200 = EXT:heboorganigram/Resources/Private/Templates/
}
tt_content {
examples_newcontentelement =< lib.contentElement
examples_newcontentelement {
templateName = NewContentElement
}
}
Then you need to place your Organigram.html file in the Templates Folder in inside the sitepackage.

How do I override the rendering of a Content Element in fluid_styled_content?

In TYPO3 8.7 I am trying to override the file Textpic.html from fluid_styled_content so that I can use my own rendering for the textpic content element.
As long as I modify the original file inside the extension itself, this is working fine.
However, I want to create my own copy of this file and use that copy. This is not working - TYPO3 does not use my own version of the file.
Here is what I did:
In the Setup field of my TypoScript template I added:
lib.contentElement.templateRootPaths.100 = /fileadmin/template/Templates/
Then I copied Textpic.html from fluid_styled_content/Resources/Private/Templates into my folder /fileadmin/template/Templates so that it becomes /fileadmin/template/Templates/Textpic.html.
Any hints, what I might be missing?
You can do this by setting constants. For example
styles.templates {
templateRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Templates/
partialRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Partials/
layoutRootPath = EXT:siteconfig/Resources/Private/Extensions/fluid_styled_content/Layouts/
}
So these locations will be checked first, if no file is there for a certain contentelement, the version of fluid_styled_content will be used.
Check the original at /typo3/sysext/fluid_styled_content/Configuration/TypoScript/constants.txt
Make sure you keep the same subfolder structure for partials.
The problem was the line
lib.contentElement.templateRootPaths.100 = /fileadmin/template/Templates/
This line is wrong. There has to be no slash at the beginning of the path.
The right line reads:
lib.contentElement.templateRootPaths.100 = fileadmin/template/Templates/
I found that in the code example of the Templating Tutorial at https://docs.typo3.org/typo3cms/TemplatingTutorial/BasicFluidTemplates/Index.html.

Get path of FAL media?

Using Fluid Template with tx_news, I need to get the URL of uploaded FAL video.
Currently I have this:
{newsItem.falMedia.0}
Which prints:
GeorgRinger\News\Domain\Model\FileReference:3
I want the output:
fileadmin/user_upload/MyVideo.mp4
newsItem.falMedia seems to be an ObjectStorage. With .0 you are pointing to the first object of it - not any function of it. In the API you can see its functions http://api.typo3.org/typo3cms/current/html/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_resource_1_1_file_reference.html or you can debug it in Fluid by using {newsItem.falMedia.0}
Example: {newsItem.falMedia.0.publicUrl} should give you the public path to the file.
If you just need url of image than use following line
{object.image.originalResource.publicUrl}..
TYPO3: get path out of file reference in Extbase
Please refer above link.

Put external css file content into html header via typoscript for a newsletter

For a newsletter I need to put the content of an external css file into the page header.
I don't want to hardcode it in the fluidtemplate but use typoscript for that purpose.
Is it possible to put the file content into a <style></style> tag rather than a <link rel .... /> file reference via typoscript?
thank you,but since the headerdata is of type CARRAY it had to be a number.
page.headerData.10 = FILE
page.headerData.10.file = path/../../file.css
page.headerData.10.wrap = <style>|</style>
With the PAGEContent Object it should be possible:
page.headerData.styles = FILE
page.headerData.styles.file = path/to/file.css
page.headerData.styles.wrap = <style>|</style>

How to convert nodes to uris in TYPO3 Neos

I created a custom node type with a link field in TYPO3 Neos 1.2.1. When I pass the property value to the template, and try to render it as a link, then an execption is thrown:
Paths must not contain two consecutive slashes.
The link property value is »node://c969f0d4-2e01-87b9-25a8-6079c5a292fe«. I have read, that the link has to be converted to an URI first. However, the suggested processor has no effect on my site.
TypoScript2
prototype(Acme.MySitePackage:Teaser) < prototype(TYPO3.Neos:Content) {
templatePath = 'resource://Acme.MySitePackage/Private/Templates/NodeTypes/Teaser.html'
title = ${q(node).property('title')}
text = ${q(node).property('text')}
image = ${q(node).property('image')}
link = ${q(node).property('link')}
link.#process.convertUris = TYPO3.Neos:ConvertUris {
#forceConversion = true
}
}
Fluid Template
<f:debug>{link}</f:debug>
<neos:link.node node="{link}" />
I bet if you keep the processor and remove the neos:link.node from your template then the
<f:debug>{link}</f:debug>
will show a http:// link to the node.
The error happens with the link ViewHelper which expects a node or node path but neither a node:// not a href:// link (maybe we should support that in the future). So you can use a plain <a href="{link}">