#90653TCA eval with uniqueInPid: allow identical value in localized content
Description
I use the TCA evaluation uniqueInPid in my extension to get unique URL fragment identifiers (“domain.com/page/#fragment”) on the same subpage.
My goal is:
- Get unique values on the same page and language.
- Values in localized content elements can be identical to the source language.
- Editors can still set a different value in localized content.
Is this possible with existing TCA? Do I miss a TCA setting which will enables this behaviour? Currently, my values in localized content elements are appended with numbers (“fragment0”).
As far as I understand, uniqueInPid does not distinguish between the different languages. I could use l10n_mode with ‘exclude’ to just use the value from the source language, but then I’d not be able to set an individual value.
If a solution does not yet exist: what do you think about a new TCA setting like “uniqueWithinLanguage” to control the behaviour of uniqueInPid?
Reviews 1
Fix this issue
Start the commit message of your patch with this. Add what the patch does, and the versions it goes to in "Releases:". The changes above were merged or abandoned: read them before you start. How to create a patch
- Commit message
-
[BUGFIX] TCA eval with uniqueInPid: allow identical value in localized content Resolves: #90653 Releases: main
Related issues 2
History 10
-
Georg Ringer changed Related to #84267 <span data-processor="relativetime" data-value="2020-03-05T22:06:07+00:00" > 03/05/20, 22:06 </span>
-
Georg Ringer changed Related to #87038 <span data-processor="relativetime" data-value="2020-03-05T22:08:11+00:00" > 03/05/20, 22:08 </span>
-
Georg Ringer commented and changed status
NewNeeds Feedback <span data-processor="relativetime" data-value="2020-03-05T22:09:46+00:00" > 03/05/20, 22:09 </span> -
Sebastian Klein commented <span data-processor="relativetime" data-value="2020-03-06T09:02:13+00:00" > 03/06/20, 09:02 </span>
Georg Ringer wrote:
> can you check if the patch of #87038 https://review.typo3.org/c/Packages/TYPO3.CMS/+/58979 would work for you?I tested this in Version 10.3.0. This patch applies only to fields with
'l10n_mode' => 'exclude'.Setting this
l10n_modewould copy the (then identical) value from the source language. But it would prevent the editor to change the value in the localized record. -
Benni Mack commented <span data-processor="relativetime" data-value="2020-03-15T09:07:05+00:00" > 03/15/20, 09:07 </span>
I mean I get what you want to do, but in general this adds quite some complexity:
What if a user changes a “language=1” news record with value “custom-de” to “language=0” (making it unique on a per-language level) – then this would need to be automatically adjusted on a per-language level. Things like “language=-1” would also be tricky to achieve.can you explain your use case?
-
Sebastian Klein commented <span data-processor="relativetime" data-value="2020-03-15T13:20:14+00:00" > 03/15/20, 13:20 </span>
Benni Mack wrote:
> I mean I get what you want to do, but in general this adds quite some complexity:
> What if a user changes a “language=1” news record with value “custom-de” to “language=0” (making it unique on a per-language level) – then this would need to be automatically adjusted on a per-language level. Things like “language=-1” would also be tricky to achieve.
>
> can you explain your use case?Example:
An editor writes about the services of his web agency. He also wants to use human-readable fragments to link to the different sections on the same page.
The result should be something like https://www.awesome-agency.com/services/#fragment
- First, he configures fragments for two content elements in the english language:
#conceptand#typo3. - Then, he wants to configure fragments for the german translation: no issues with the first content element, he can use
#konzeptionhere. But when he tries to configure#typo3for the second CE, the result will betypo30instead.
The basic problem:
While for many text sections the corresponding fragments could be localized quite easily, brand names etc. are an issue. You could use
#ueber-typo3in my example instead.
What about a professional article with many technical terms, though? I’d consider it unpleasant to use#ueber-optionsplit,#ueber-parsefuncand so on.But I’m now aware that the necessary changes to
uniqueInPidare more complex than I initially thought. You must decide if you want to add more complexity to this part of TYPO3.*Side note:*
When a content element with the fragment#exampleis moved to a new page, the uniqueness of this fragment will automatically be checked during the copy process. If another CE on the new page already contains the identical fragment, the fragment of the copied CE will then be changed to#example0.
I guess that this check could be performed as well when the content element’ssys_language_uidis changed. The several localization modes of TYPO3 may require a more complex solution, though. - First, he configures fragments for two content elements in the english language:
-
Michael Rainer commented <span data-processor="relativetime" data-value="2020-12-14T15:45:24+00:00" > 12/14/20, 15:45 </span>
Sebastian Klein wrote in #note-6:
> Benni Mack wrote:
> > I mean I get what you want to do, but in general this adds quite some complexity:
> > What if a user changes a “language=1” news record with value “custom-de” to “language=0” (making it unique on a per-language level) – then this would need to be automatically adjusted on a per-language level. Things like “language=-1” would also be tricky to achieve.
> >
> > can you explain your use case?
>
> Example:*
>
> An editor writes about the services of his web agency. He also wants to use human-readable fragments to link to the different sections on the same page.
>
> The result should be something like _https://www.awesome-agency.com/services/#fragment_
>
> * First, he configures fragments for two content elements in the *english language:#conceptand#typo3.
> * Then, he wants to configure fragments for the german translation: no issues with the first content element, he can use#konzeptionhere. But when he tries to configure#typo3for the second CE, the result will betypo30instead.
>
> *The basic problem:*
>
> While for many text sections the corresponding fragments could be localized quite easily, brand names etc. are an issue. You could use#ueber-typo3in my example instead.
> What about a professional article with many technical terms, though? I’d consider it unpleasant to use#ueber-optionsplit,#ueber-parsefuncand so on.
>
> But I’m now aware that the necessary changes touniqueInPidare more complex than I initially thought. You must decide if you want to add more complexity to this part of TYPO3.
>
> *Side note:*
> When a content element with the fragment#exampleis moved to a new page, the uniqueness of this fragment will automatically be checked during the copy process. If another CE on the new page already contains the identical fragment, the fragment of the copied CE will then be changed to#example0.
> I guess that this check could be performed as well when the content element’ssys_language_uidis changed. The several localization modes of TYPO3 may require a more complex solution, though.Hi Sebastian,
hi Benni,I’ve exactly the same problem like Sebastian described.
My example is about a hotel website, where the customer could create rooms and they are visible as detail pages in the frontend.
Every room should have a clean unique URL ( like /en/rooms/pool-suite), but in the german translation, the room should also be called pool-suite and
with uniqueInPid, it gets converted to pool-suite0.
An Option like uniqueInPidAndLanguage would be cool, but I know, that’s a lot of work and also complicate to achieve and to maintain.Benni If there is nothing planned for this case, what would be a good solution? May you give me a good hint?Sebastian: What was your solution?Thanks in advance.
Cheers,
Michael -
Tanel Põld commented and changed TYPO3 Version
911 PHP Version 7.4 <span data-processor="relativetime" data-value="2021-11-17T10:00:23+00:00" > 11/17/21, 10:00 </span>Ran into the same problem…
I’ll add another use case.
I’m using ‘uniqueInPid’ in company with ‘allowLanguageSynchronization’ => true.
The field is “URL segment & unique ID” for pagination. It’s unique to allow multiple paginators to function separate from each other on the same page.
In many cases the translation could be the same as original but never the same as in other elements in same language.
-
Christian Hackl commented <span data-processor="relativetime" data-value="2025-11-27T16:35:53+00:00" > 11/27/25, 16:35 </span>
Run in this problem too.
In my case, I have to retrieve data from external sources and merge it with my own data records. To do this, a unique ID is used (which the editor has to enter) to link the data records together. The external data consists of prices, for example (the language doesn’t matter here, as the prices are the same in every language). So I have translated data records that share the same ID but still have to be unique for each different data record.
———————-
I would perhaps suggest another solution that could also help with other problems of this kind:
If you could create a custom “eval” that contained more information, for example, which table you are currently in and in which language the record is written—in other words, basically the “record”-information is missing. Then you could simply create such evaluations yourself.
-
Georg Ringer changed status
Needs FeedbackAccepted <span data-processor="relativetime" data-value="2026-10-07T19:46:09+00:00" > 10/07/26, 19:46 </span>
can you check if the patch of #87038 https://review.typo3.org/c/Packages/TYPO3.CMS/+/58979 would work for you?
I don’t know the reason why there is no backport to 9.5 is planned (yet)
thanks