Bug #91342
openNo PID is checked in FE when TCA slug field has uniqueInPid in eval
0%
Description
I really like eval options uniqueInSite and uniqueInPid in the slug field. But I don't understand how the uniqueInPid option is resolved in the frontend.
In my project I have similar structure to this:
- Folder A
- Folder B
- Detail page A ... (Record storage in the Plugin tab is set to "Folder A")
- Detail page B ... (Record storage in the Plugin tab is set to "Folder B")
Suppose we have our own object type (eg. Project) and different types of projects stored in different folders. 1st type is stored in "Folder A" and displayed on "Detail page A", 2nd type use "Folder B" and "Detail page B". When I save two different projects with the same name in different folders, the same slug will be generated for them (eg. big-project), which is fine due to the uniqueInPid option.
Now, in the frontend I get two different URLs:
- /detail-page-a/big-project ... (should display project from "Folder A")
- /detail-page-b/big-project ... (should display project from "Folder B")
But in both cases the first "big-project" from table is displayed, the record storage (field [pages]) is ignored. The TYPO3\CMS\Core\Routing\Aspect\PersistedAliasMapper
use language and frontend (deleted, hidden etc.) restrictions but there is no check for PID.
Is this a misconfiguration or a bug?
Updated by Jiří Štefl over 4 years ago
- Subject changed from No PID is checked when TCA slug field has uniqueInPid in eval to No PID is checked in FE when TCA slug field has uniqueInPid in eval
Updated by Bernhard Eckl over 3 years ago
Same problem here. In the frontend the first record found is checked no matter which pid is assigned. How to fix it?
Updated by Rémy DANIEL over 1 year ago
It is more that the uniqueInPid is suitable if the slug contains also the rootline, which it is not the case for records other than pages.
When PersistedAliasMapper decode an url segment (slug) to a record uid, he has actually no way to restrict the db query in a particular pid (where this pid should be encoded in the url ?)
IMHO, the only solution is to always add the uid of the record to the generatorOptions/fields: uniqueInPid is then obviously useless.
'config' => [
'type' => 'slug',
'generatorOptions' => [
'fields' => ['uid','title'],
'fieldSeparator' => '/',
'replacements' => [
'/' => '',
],
],
'fallbackCharacter' => '-',
],