I'm using HTMLPurifier and even thou I have :
$config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
it removes all 'target' attribues from the links.
Any idea why is it doing it?
The list of allowed frame targets is not enabled by default. You have to enable it manually.
In a Yii2 application, inside of a DetailView, I configured HtmlPurifier as follows:
[
'label' => 'Document PDF',
'format'=> 'raw',
'value' => HtmlPurifier::process(DocumentFunctions::viewDocumentPdfInView($model->document_id), [
'Attr.AllowedFrameTargets' => ['_blank'],
]),
],
Here is a simpler way I found:
[
'label' => 'Document PDF',
'format'=> ['html', 'config' => ['Attr.AllowedFrameTargets' => ['_blank']]],
'value' => DocumentFunctions::viewDocumentPdfInView($model->document_id),
]
Related
I have made a custom palette in tt_content.php and want to add it to all content elements on the appearance tab like this:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes(
'tt_content',
'--palette--;My Palette;my_palette',
'',
'before:sectionIndex'
);
This works for everything except Grid Elements (gridelements_pi1). How do I make the new palette show up on Grid Elements as well?
The comment from #MathiasBrodala lead me to finding the answer is in the order of extensions.
In this case I needed to add gridelements under suggests in my ext_emconf.php which ensures it will be loaded before my site package.
$EM_CONF[$_EXTKEY] = [
'title' => 'My Package',
'description' => 'TYPO3 Sitepackage',
'category' => 'templates',
'version' => '1.0.0',
'state' => 'stable',
'constraints' => [
'depends' => [
'typo3' => '8.7.0-9.5.99',
'fluid_styled_content' => '8.7.0-9.5.99'
],
'suggests' => [
'gridelements' => '9.3.0-0.0.0',
],
'conflicts' => [
],
],
'uploadfolder' => 0,
'createDirs' => '',
'clearCacheOnLoad' => 1
];
I created a custom content element with TYPO3 ver. 10.4.21, but I have a problem.
Problem: showing up same Fields on every edit page of content elements.
I want to use own fields only on my custom content element (for my flipbox-content element). But if I select e.g. a regular text element, then I can see my own fields on the edit page by the text element too.
I wrote the codes in TCA/Overrides/tt_content.php:
###############################################
# Front side #
###############################################
// front side header
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_frontsideheader' => [
'exclude' => 0,
'label' => 'Front side header',
'config' => [
'type' => 'text',
'renderType' => 'input',
'items' => [
[
0 => '',
1 => ''
]
],
],
],
]
);
// front side bodytext
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_frontsidebodytext' => [
'label' => 'Front side bodytext',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 15,
'enableRichtext' => true,
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'general',
'tx_pagesaddfields_frontsideheader, tx_pagesaddfields_frontsidebodytext',
'after:tx_container_parent'
);
###############################################
# Back side #
###############################################
// back side header
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_backsideheader' => [
'exclude' => 0,
'label' => 'Back side header',
'config' => [
'type' => 'text',
'renderType' => 'input',
'items' => [
[
0 => '',
1 => ''
]
],
],
],
]
);
// back side bodytext
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns(
'tt_content',
[
'tx_pagesaddfields_backsidebodytext' => [
'label' => 'Back side bodytext',
'config' => [
'type' => 'text',
'cols' => 40,
'rows' => 15,
'enableRichtext' => true,
],
],
]
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'general',
'tx_pagesaddfields_backsideheader, tx_pagesaddfields_backsidebodytext',
'after:tx_pagesaddfields_frontsidebodytext'
);
I know because I wrote "addTCAcolumns('tt_content'). But I don't know how I can rewrite them to let show up my new fields only on my custom edit page.
Is it the right page to chage it?:
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/ExtendingTca/Examples/Index.html
(by exanple1) and
https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/User/Index.html#columns-user?
I tried to do it, but it didn't work on my site. Unfortunately, I don't have enough experiences with PHP... If you know other website or if you can explain here, please write it down here.
I hope anyone can help me. Thank you.
It is best practice to add one file into TCA/Overrides/ per custom content element. The name is up to you, TYPO3 reads all .php files in this folder. content_element_<your_ctype>.php or tt_content_<your_ctype>.php are used as name quite often.
https://github.com/benjaminkott/bootstrap_package/blob/master/Configuration/TCA/Overrides/203_content_element_card_group.php
Here you can see how it is done in the bootstrap_package for the custom content element with the CType card_group
In line 42 $GLOBALS['TCA']['tt_content']['types']['card_group'] the configuration is limited to ['(C)type']['card_group'] and the 'showitem' => ' tells TYPO3 what and how to show fields for this content element.
From line 70 on you can see how to set a new field, in line 49 you can see how it was added.
I am using mewebstudio/Purifier in my Laravel project.
I have a custom vue-component <image-slides> which can be created by the user, and a want to store it into database, so
user input example:
<h2>My Title</h2><image-slides images="https://i.imgur.com/123.jpg,https://i.imgur.com/321.jpg"></image-slides><p>some text</p>
when using default Purifier config:
clean('<h2>My Title</h2><image-slides images="https://i.imgur.com/123.jpg,https://i.imgur.com/321.jpg"></image-slides><p>some text</p>');
=> "<h2>My Title</h2><p>some text</p>"
I add the <image-slides> to the config/purifier.php
return [
'encoding' => 'UTF-8',
'finalize' => true,
'ignoreNonStrings' => false,
'cachePath' => storage_path('app/purifier'),
'cacheFileMode' => 0755,
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Transitional',
// before
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,ol[start],li,p[style],br,span[style],img[width|height|alt|src],*[style|class],pre,hr,code,h2,h3,h4,h5,h6,blockquote,del,table,thead,tbody,tr,th,td',
// after
'HTML.Allowed' => 'div,b,strong,i,em,a[href|title],ul,ol,ol[start],li,p[style],br,span[style],img[width|height|alt|src],*[style|class],pre,hr,code,h2,h3,h4,h5,h6,blockquote,del,table,thead,tbody,tr,th,td,image-slides[images]',
...
But I got error:
Element 'image-slides' is not supported (for information on implementing this, see the support forums)
I already clean the cache for both laravel and purifier(remove /storage/app/purifier folder)
How can I add a custom tag for Purifier?
just define it in config/purifier.php
return [
'settings' => [
'default' => [
'HTML.Allowed' => 'image-slide[images]'
],
'custom_elements' => [
['image-slides', 'Block', 'Flow', 'Common', [
'images' => 'Text'
]]
]
]
];
I want to render/show an image in a view on backend, but the image location is in frontend/web/uploads.
I tried doing this on the DetailView::widget():
...
[
'attribute'=>'image',
'value'=>('/frontend/web/uploads/'.$model->image),
'format' => ['image',['width'=>'100','height'=>'100']],
],
But the image is not showing up. Any help?
Yes it is possible to access frontend/web/uploads to backend view.
First add urlManagerFrontend in backend->config->main.php like
'components' => [
'urlManagerFrontend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => 'frontend/web/', //Access frontend web url
],
],
And then access the frontend/web/ to the backend like
Yii::$app->urlManagerFrontend->baseUrl.'/uploads/your_image.jpg'
In DetailView::widget like
[
'attribute'=>'image',
'value'=> function ($model) {
return Html::img(Yii::$app->urlManagerFrontend->baseUrl.'/uploads/'.$model->image, ['alt' => 'No Image', 'width' => '10px', 'height' => '10px']);
},
'format' => 'raw',
],
If this is the only place where you're linking to frontend from backend, the easiest way would be defining alias in your backend config:
Yii::setAlias('#frontendUploads', 'https://repasca.devs/uploads');
And use this alias for building file URL:
[
'attribute' => 'image',
'value' => Yii::getAlias('#frontendUploads') . '/' . $model->image,
'format' => ['image', ['width' => '100', 'height' => '100']],
],
I am using Mews HTML Purifier and have it working great!
However, there are a couple of HTML5 elements such as figure that I want to not be stripped out.
I have looked at the docs:
http://htmlpurifier.org/docs/enduser-customize.html
But cannot see any information on adding elements / the full config options for when using the Laravel config file.
I cant find information when setting up the config like this:
return [
'encoding' => 'UTF-8',
'finalize' => true,
'cachePath' => storage_path('app/purifier'),
'settings' => [
'default' => [
'HTML.Doctype' => 'XHTML 1.0 Strict',
'HTML.Allowed' => 'img[alt|src],ul,li,p,br,b,figure',
'CSS.AllowedProperties' => '',
//'AutoFormat.AutoParagraph' => true,
'AutoFormat.RemoveEmpty' => true,
],
'test' => [
'Attr.EnableID' => true
],
"youtube" => [
"HTML.SafeIframe" => 'true',
"URI.SafeIframeRegexp" => "%^(http://|https://|//)(www.youtube.com/embed/|player.vimeo.com/video/)%",
],
],
];
And then using it like:
Purifier::clean($request->content);