Typo3 9.5 UrlLinkHandler - typo3

I'm trying to use the UrlLinkHandler in Typo3 9.5. So far I've configured my Backend with TCEMain.
TCEMAIN.linkHandler.youtube {
handler = TYPO3\CMS\Recordlist\LinkHandler\UrlLinkHandler
label = Youtube
}
This works fine so far and I can add links within the RTE.
For rendering the Link in the frontend my Typoscript looks like this:
config {
recordLinks.youtube {
typolink {
wrap = test|test
}
}
}
But the frontend just shows a regular rendered anchor tag like Link.
Any hints what I'm doing wrong?

Oehm, you're mixing up different things... You register a new UrlLinkHandler for BE, but your recordLinks-block for FE is a part of the RecordLinkHandler.
If you want to have a link-type formatted in a special (like you described on typo3.net), then an own LinkHandler could be a solution.

Related

No default link classes in typo3 8 anymore?

In V7 all internal/external/download links got an additional class by default, like 'internal-link' or 'download'.
Looks like in V8 with the new CKEditor this feature is gone.
Is there a way to reimplement it via typoScript or some kind of yaml RTE config?
An automatic solution, not the solution where the user have to pick a custom style, thats our current workaround.
If these classes should be applied automatically to specific link types without enabling the editors to change those classes, you should go for TypoScript parseFunc:
https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Parsefunc.html?highlight=parsefunc
Especially makeLinks, tags and typolink should be useful here:
https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Makelinks.html#makelinks
https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Tags.html#tags
https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink.html#atagparams
For example you would assign a specific class to an external http link automatically created by makelink like this:
parseFunc {
makelinks = 1
makelinks {
http {
keep = path
extTarget = _blank
ATagParams = class="external-link"
}
}
}

Custom tags in TYPO3 content

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)

TYPO3 7.6.15 cannot define rooth path for a custom partial

I created contact form in TYPO3 7.6.15 using standard form extension. I also created custom partial for it, and I defined it inside of my root template setup:
plugin.tx_form {
partialRootPaths {
20 = fileadmin/templates/ext/form/partials
}
}
Unfortunately it doesn't work and I am not sure why. I saw that the form extension for this TYPO3 version is still in beta phase...
Any help is greatly appreciated!
Denis
In the TYPO3 object browser, the paths to templates, layouts and partials are located in the object "view". So please try this:
plugin.tx_form {
view {
partialRootPaths.20 = fileadmin/templates/ext/form/partials/
}
}

CKEditor automatically strips classes from div

I am using CKEditor as a back end editor on my website. It is driving me round the bend though as it seems to want to change the code to how it sees fit whenever I press the source button. For example if I hit source and create a <div>...
<div class="myclass">some content</div>
It then for no apparent reason strips the class from the <div>, so when I hit source again it has been changed to...
<div>some content</div>
I presume this irritating behaviour can be turned off in the config.js, but I have been digging and cant find anything in documentation to turn it off.
Disabling content filtering
The easiest solution is going to the config.js and setting:
config.allowedContent = true;
(Remember to clear browser's cache). Then CKEditor stops filtering the inputted content at all. However, this will totally disable content filtering which is one of the most important CKEditor features.
Configuring content filtering
You can also configure CKEditor's content filter more precisely to allow only these element, classes, styles and attributes which you need. This solution is much better, because CKEditor will still remove a lot of crappy HTML which browsers produce when copying and pasting content, but it will not strip the content you want.
For example, you can extend the default CKEditor's configuration to accept all div classes:
config.extraAllowedContent = 'div(*)';
Or some Bootstrap stuff:
config.extraAllowedContent = 'div(col-md-*,container-fluid,row)';
Or you can allow description lists with optional dir attributes for dt and dd elements:
config.extraAllowedContent = 'dl; dt dd[dir]';
These were just very basic examples. You can write all kind of rules - requiring attributes, classes or styles, matching only special elements, matching all elements. You can also disallow stuff and totally redefine CKEditor's rules.
Read more about:
Content filtering in CKEditor – why do you need content filter.
Advanced Content Filter – in deep description of the filtering mechanism.
Allowed content rules – how to write allowed content rules.
I found a solution.
This turns off the filtering, it's working, but not a good idea...
config.allowedContent = true;
To play with a content string works fine for id, etc, but not for the class and style attributes, because you have () and {} for class and style filtering.
So my bet is for allowing any class in the editor is:
config.extraAllowedContent = '*(*)';
This allows any class and any inline style.
config.extraAllowedContent = '*(*);*{*}';
To allow only class="asdf1" and class="asdf2" for any tag:
config.extraAllowedContent = '*(asdf1,asdf2)';
(so you have to specify the classnames)
To allow only class="asdf" only for p tag:
config.extraAllowedContent = 'p(asdf)';
To allow id attribute for any tag:
config.extraAllowedContent = '*[id]';
etc etc
To allow style tag (<style type="text/css">...</style>):
config.extraAllowedContent = 'style';
To be a bit more complex:
config.extraAllowedContent = 'span;ul;li;table;td;style;*[id];*(*);*{*}';
Hope it's a better solution...
Edit: this answer is for those who use ckeditor module in drupal.
I found a solution which doesn't require modifying ckeditor js file.
this answer is copied from here. all credits should goes to original author.
Go to "Admin >> Configuration >> CKEditor"; under Profiles, choose your profile (e.g. Full).
Edit that profile, and on "Advanced Options >> Custom JavaScript configuration" add config.allowedContent = true;.
Don't forget to flush the cache under "Performance tab."
Since CKEditor v4.1, you can do this in config.js of CKEditor:
CKEDITOR.editorConfig = function( config ) {
config.extraAllowedContent = '*[id](*)'; // remove '[id]', if you don't want IDs for HTML tags
}
You can refer to the official documentation for the detailed syntax of Allowed Content Rules
if you're using ckeditor 4.x you can try
config.allowedContent = true;
if you're using ckeditor 3.x you may be having this issue.
try putting the following line in config.js
config.ignoreEmptyParagraph = false;
This is called ACF(Automatic Content Filter) in ckeditor.It remove all unnessary tag's What we are using in text content.Using this command in your config.js file should be turn off this ACK.
config.allowedContent = true;
Please refer to the official Advanced Content Filter guide and plugin integration tutorial.
You'll find much more than this about this powerful feature. Also see config.extraAllowedContent that seems suitable for your needs.
Following is the complete example for CKEDITOR 4.x :
HTML
<textarea name="post_content" id="post_content" class="form-control"></textarea>
SCRIPT
CKEDITOR.replace('post_content', {
allowedContent:true,
});
The above code will allow all tags in the editor.
For more Detail : CK EDITOR Allowed Content Rules
If you use Drupal AND the module called "WYSIWYG" with the CKEditor library, then the following workaround could be a solution. For me it works like a charm. I use CKEditor 4.4.5 and WYSIWYG 2.2 in Drupal 7.33. I found this workaround here: https://www.drupal.org/node/1956778.
Here it is:
I create a custom module and put the following code in the ".module" file:
<?php
/**
* Implements hook_wysiwyg_editor_settings_alter().
*/
function MYMODULE_wysiwyg_editor_settings_alter(&$settings, $context) {
if ($context['profile']->editor == 'ckeditor') {
$settings['allowedContent'] = TRUE;
}
}
?>
I hope this help other Drupal users.
I found that switching to use full html instead of filtered html (below the editor in the Text Format dropdown box) is what fixed this problem for me. Otherwise the style would disappear.
I would like to add this config.allowedContent = true; needs to be added to the ckeditor.config.js file not the config.js, config.js did nothing for me but adding it to the top area of ckeditor.config.js kept my div classes
Another option if using drupal is simply to add the css style that you want to use. that way it does not strip out the style or class name.
so in my case under the css tab in drupal 7 simply add something like
facebook=span.icon-facebook2
also check that font-styles button is enabled
I face same problem on chrome with ckeditor 4.7.1. Just disable pasteFilter on ckeditor instanceReady.This property disable all filter options of Advance Content Filter(ACF).
CKEDITOR.on('instanceReady', function (ev) {
ev.editor.pasteFilter.disabled = true;
});

TYPO3 Extension output altered by TYPO3?

TYPO3 seems to alter the output of my Frontend extension.
Simple Testcase:
function main($content, $conf)
{
$this->conf = $conf;
$this->pi_setPiVarDefaults();
$this->pi_loadLL();
return 'test';
}
When I call a page with this extension in the frontend i get:
test
Basically it prepends the path I used to access the page to the anchor link.
What could be responsible for this behaviour? RealURL?
How can I disable it?
You probably have somwhere in your TS template (in Setup) enabled prefixing:
config.prefixLocalAnchors = all
Note, that if you have set config.baseURL=http://some.tld/ and enabled RealURL this is required, otherwise all anchor links will be redirected to the main page:
http://some.tld/#test
instead of
http://some.tld/pagename/sub/other-sub#test