-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workspace version of record does not accept same content slug due to uniqueInPid #7
Comments
I wasn't sure about |
Thank you for your report. I'll look into Workspaces. Please note: I did not apply your patch to test the exact behaviour. But you adjusted the TCA close to a former state of this extension. As you can see from the commit message, using the TCA type When I finished the fragment hook for page links, I can revisit the TCA of the fragment field. |
Thanks for pointing this out. Indeed, it would add a default-[a-z0-9]{10} value if the content element header would be empty, so i changed it to allow to stay empty if the header is empty using postModifiers in the tca configuration for the field. In my special use case it will make sense to have a slug for each content element where the header field is filled. By having it this way editors are not forced to set the slug initially after adding a content element. Updated patch, if of interest--- /dev/null
+++ Classes/FormEngine/Slug.php
@@ -0,0 +1,23 @@
+<?php
+declare(strict_types = 1);
+
+namespace Sebkln\ContentSlug\FormEngine;
+
+use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSlug;
+use TYPO3\CMS\Core\DataHandling\SlugHelper;
+
+class Slug
+{
+ public function getPrefix(array $parameters, TcaSlug $reference): string
+ {
+ return '#';
+ }
+
+ public function modifySlug(array $parameters, SlugHelper $reference): string
+ {
+ if (preg_match('~^default-[a-z0-9]{10}$~s', $parameters['slug'])) {
+ $parameters['slug'] = '';
+ }
+ return $parameters['slug'];
+ }
+}
--- Configuration/TCA/Overrides/tt_content.php
+++ Configuration/TCA/Overrides/tt_content.php
@@ -7,16 +7,25 @@
'exclude' => true,
'label' => 'LLL:EXT:content_slug/Resources/Private/Language/locallang_db.xlf:tt_content.tx_content_slug_fragment',
'config' => [
- 'type' => 'input',
+ 'type' => 'slug',
'size' => 50,
'max' => 80,
- 'eval' => 'trim,Sebkln\\ContentSlug\\Evaluation\\FragmentEvaluation,uniqueInPid',
- 'default' => '',
- 'fieldControl' => [
- 'importControl' => [
- 'renderType' => 'generateFragmentFromHeaderControl'
- ]
- ]
+ 'generatorOptions' => [
+ 'fields' => ['header'],
+ 'fieldSeparator' => '-',
+ 'replacements' => [
+ '/' => '-'
+ ],
+ 'postModifiers' => [
+ \Sebkln\ContentSlug\FormEngine\Slug::class . '->modifySlug',
+ ],
+ ],
+ 'appearance' => [
+ 'prefix' => \Sebkln\ContentSlug\FormEngine\Slug::class . '->getPrefix',
+ ],
+ 'fallbackCharacter' => '-',
+ 'eval' => 'trim,Sebkln\\ContentSlug\\Evaluation\\FragmentEvaluation,uniqueInPid',
+ 'default' => ''
],
],
'tx_content_slug_link' => [
|
Like you statet in issue #3 about language versions, there's an issue with the content slug and workspaces (versions of records), too.
I changed the tca of the field to use the slug type in TYPO3 core and added a prefix class with a local composer patch:
Now I'm totally allowed to stay on the defined content slug in the workspace version of the record:
Maybe this is of interest for you, too.
Cheers
Jens
The text was updated successfully, but these errors were encountered: