mirror of
https://github.com/flextype/flextype.git
synced 2025-08-14 00:54:03 +02:00
fix(entries): fix wrong Implementation of Slug Field for Entries #452
- add new field `id` BREAKING CHANGES use field `id` to get entry path instead of `slug` field
This commit is contained in:
14
src/flextype/app/Foundation/Entries/Fields/IdField.php
Normal file
14
src/flextype/app/Foundation/Entries/Fields/IdField.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (https://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
if ($flextype->registry->get('flextype.settings.entries.fields.id.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['id'] = isset($flextype->entries->entry['id']) ? (string) $flextype->entries->entry['id'] : (string) ltrim(rtrim($flextype->entries->entry_path, '/'), '/');
|
||||
});
|
||||
}
|
@@ -9,6 +9,7 @@ declare(strict_types=1);
|
||||
|
||||
if ($flextype->registry->get('flextype.settings.entries.fields.slug.enabled')) {
|
||||
$flextype->emitter->addListener('onEntryAfterInitialized', function () use ($flextype) : void {
|
||||
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) ltrim(rtrim($flextype->entries->entry_path, '/'), '/');
|
||||
$parts = explode('/', ltrim(rtrim($flextype->entries->entry_path, '/'), '/'));
|
||||
$flextype->entries->entry['slug'] = isset($flextype->entries->entry['slug']) ? (string) $flextype->entries->entry['slug'] : (string) end($parts);
|
||||
});
|
||||
}
|
||||
|
@@ -79,7 +79,9 @@ entries:
|
||||
enabled: true
|
||||
uuid:
|
||||
enabled: true
|
||||
|
||||
id:
|
||||
enabled: true
|
||||
|
||||
# Cache
|
||||
#
|
||||
# - enabled: Set to true to enable caching
|
||||
|
Reference in New Issue
Block a user