Skip to content

Workspace version of record does not accept same content slug due to uniqueInPid #7

Description

@jacobsenj

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:

--- /dev/null
+++ Classes/FormEngine/SlugPrefix.php
@@ -0,0 +1,14 @@
+<?php
+declare(strict_types = 1);
+
+namespace Sebkln\ContentSlug\FormEngine;
+
+use TYPO3\CMS\Backend\Form\FormDataProvider\TcaSlug;
+
+class SlugPrefix
+{
+    public function getPrefix(array $parameters, TcaSlug $reference): string
+    {
+        return '#';
+    }
+}

--- Configuration/TCA/Overrides/tt_content.php
+++ Configuration/TCA/Overrides/tt_content.php
@@ -7,16 +7,22 @@
         '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' => [
+                    '/' => '-'
+                ],
+            ],
+            'appearance' => [
+                'prefix' => \Sebkln\ContentSlug\FormEngine\SlugPrefix::class . '->getPrefix',
+            ],
+            'fallbackCharacter' => '-',
+            'eval' => 'trim,Sebkln\\ContentSlug\\Evaluation\\FragmentEvaluation,uniqueInPid',
+            'default' => ''
         ],
     ],
     'tx_content_slug_link' => [

Now I'm totally allowed to stay on the defined content slug in the workspace version of the record:

image

Maybe this is of interest for you, too.

Cheers
Jens

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions