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.
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)
How can I add some fields to the TYPO3 template (or a better location) for general site info?
For example, a phone number field so that I can add it to the site header or other non content area.
In the past I have used content elements in a special folder to add something like this, but that's not very user friendly for site editors.
If you want it to be (relatively) easy for site editors to edit, without building a custom module or something like that, content elements in a special folder is your best bet. We often use custom content elements for this so the field are more logical, but you do need to do some programming for this. More on creating custom fields can be found at https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/ContentElements/AddingYourOwnContentElements.html
An alternative could be using a TypoScript constant. These are relatively easy to edit using the Constants editor in the Template module. Assuming you use Fluid templates, you can add it to your template with <f:cObject typoscriptObjectPath="lib.phoneNumber" /> In TypoScript you then add the following:
lib.phoneNumber = TEXT
lib.phoneNumber.value = {$phoneNumber}
More about the Constants editor can be found at https://docs.typo3.org/m/typo3/reference-typoscript/master/en-us/UsingSetting/TheConstantEditor.html
in both other answers I miss the simplest solution:
defining the value as a generic fluid variable
page {
10 = FLUIDTEMPLATE
10 {
:
variables {
:
phoneNumber = TEXT
phoneNumber.value = {$phoneNumber}
}
}
}
You do not need to use settings as it is no setting.
or jumping back from fluid to typoscript with lib.anything and a call to f:cObject viewhelper.
Aside of that I would recommend to consider if it is ok to need an admin (or even a maintainer to deploy a new version) to change that phone number (all typoscript, setup and constants, belongs into the site-extensions which is provided in a repository).
you always could restrict normal editors from accessing special pages or even columns or special content elements, where an admin can change data without a deploy-process.
(example: How much hassle it is if you need to change the number in case of emergency because of a breakdown of phone lines?)
I think the easiest way is to add it with TS, something like that :
page {
10 {
settings {
siteInfos {
phone = 01 02 03 04 05
}
}
}
}
And then , you can use this in you Fluid Templates :
{settings.siteInfos.phone}
Florian
Is there a way to get the Log In Form for Frontend User on every page? I would prefer the footer.
And if someone is logged in you can see the Log Out Button.
Is this possible without an extension?
You can copy the default felogin output to wherever you want on your template. For example use lib.login, copy the plugin.tx_felogin_pi1 into it, change the template and you're fine.
lib.login < plugin.tx_felogin_pi1
lib.login.templateFile = path/to/your/template/file
More you can see in the official documentation: https://docs.typo3.org/typo3cms/extensions/felogin/8.7/Configuration/Index.html
In general there are three options to include a CE (e.g. the Login-form) on all pages:
use typoscript to generate the CE. Normally the CEs are defined in tt_content, from where you could copy the base configuration and adapt it. For some plugins you also find a complete configuration beyond lib (for newer extensions there you only find the settings). All the configuration must be done in typoscript.
use typoscript to render the content of a special page/ column. In this variant you have a special page only for content referenced somewhere else. Advantage: you could configure the CE in the usual way. Try to avoid referencing CEs by uid as an editor might disable or delete the current element(s) and insert a new one which would not be rendered.
use a special column in your root page and inherit the content to all subpages. Advantage: you could change the inherited content easily on each page (if this column is available in the current backend layout).
example for 3:
variables {
footer_content < styles.content.get
footer_content.select.where = colPos = 15
footer_content.slide = -1
}
I would like to create a "cleanup" extension that replaces various characters (quotes by guillemets) in all kinds of textfields in TYPO3.
I thought about extending <f:format.html> or parseFunc, but I don't know where to "plug in" so I get to replace output content easily before it's cached.
Any ideas, can you give me an example?
If you don't mind regexing, try this:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['cleanUpQuotes'][] = \NAMESPACE\Your\Extension::class;
Insert it into ext_localconf.php and this part is done.
The next step is the class itself:
public function cleanUpQuotes(TypoScriptFrontendController $parentObject)
{
$parentObject->content = DO_YOUR_THING_HERE
}
There also is another possibility which could replace any strings in the whole page - as it operates on the rendered page (and not only on single fields).
You even can use regular expressions.
Look at my answer -> here
new here, and also new to TYPO3.
I need to put something like [imagebox, title='box1'] into content editor and that will be replaced by a text and image with some javascript effect (text and image are managed in the DB elsewhere, the tag is just for the placement in the page).
I've read that TYPO3 has a mechanism for adding custom tags and I managed to make them accepted in the RTE.
I tried instead of [imagebox..... to use
<imagebox>box1</imagebox>
with something like this (copied from web):
tt_content.text.20.parseFunc.tags {
imagebox < lib.parseFunc.tags.link
imagebox = TEXT
imagebox.value= replaced
# imagebox = PHP_SCRIPT
# imagebox {
# stripNL = 0
# Pass a parameter from Typoscript to a PHP script:
# UID of the page containing the SINGLE view of tt_news
# id_singleView = 18
# Call the PHP script
# file = fileadmin/scripts/imagebox_parser.php
# }
}
lib.parseFunc.tags.imagebox < tt_content.text.20.parseFunc.tags.imagebox
should be able to replace content between tags.
I've commented call to php function just tried to get a text replacement for starters.
I've put that in the main root template Setup, but nothing is replaced.
I've also tried other examples from the web with no success.
Did anyone have situation like this?
Are there better approaches for that in TYPO3? (I'm using v7.6.23)
Any suggestion or hint is appreciated.
EDIT: using FSC on textmedia element
I think your examples are outdated. (the object PHP_SCRIPT is obsolete for a long time)
You might have a look at the documentation for your TYPO3 version:
https://docs.typo3.org/typo3cms/TyposcriptReference/7.6/Functions/Parsefunc/
you also need to enhance the parsefunc where you need it. That can depend on:
CSC or FSC?
which kind of content element (CE) do you use? (be sure to enhance the rendering of that CE)