Check Link Type For TYPO3 / FLUID Template
In my typo3 project I have a fluid template that renders bodytext from CMS:
<f:section name="Main">
<div class="RteContent">
<f:format.html>{data.bodytext}</f:format.html>
</div>
</f:section>
Now, in the RTE you can set links for files or links for pages. My goal is to have a different styling for file links. Is there any way to find out what kind of links are being set and then apply an according CSS style for this type of file link?
Answer
parseFunc
The HTML output of RTE content is controlled by a parseFunc
(see https://docs.typo3.org/other/typo3/view-helper-reference/master/en-us/typo3/fluid/latest/Format/Html.html). The default is lib.parseFunc_RTE
but you can use your own.
If you are a TypoScript magician (I am not) it can do pretty amazing things (https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/Functions/Parsefunc.html#makelinks). I would look into makelinks.http.ATagParams
(stdWrap).
CSS
Yet there is probably a much easier way. By using TYPO3's fixed file storage URL to our advantage we can use CSS selectors to match links to files.
This might need adapting depending on your configuration which might influence link generation (config.baseUrl
/absRefPrefix
)
a[href*="/fileadmin/"] {
background: yellow
}
or
a[href^="/fileadmin/"] {
background: yellow
}
or
a[href$=".pdf"] {
background: yellow
}
Related Questions
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → How to dynamically add class to parent div of focused input field?
- → Expanding search bar not expanding before search
- → Include external javaScript CSS in laravel 5
- → Using css modules how do I define a global class
- → How to add a timer in HTML5 and Javascript?
- → Conditional BG Color on AngularJS
- → Divs aren't aware of screen resizing
- → Setting the height of a textarea inside a table
- → How can I get Greasemonkey to highlight visited image links?
- → How to handle onclick event of a button?