Conversation
instead of StringUtil::generateAlias
|
I don't think that's possible in form like that, because you can have multiple website roots with different configurations and the tags are not tied to website roots. This could be a setting in the tag manager configuration, though, maybe. |
|
So, the tag manager would have two optional extra configuration items: locale (defaults to 'en') and validChars (defaults to '0-9a-z' in /src/DependencyInjection/Configuration.php) The /src/Manager/DefaultManager.php (and /src/Manager/ManagerInterface.php) would get two new methods: getLocale() and getValidChars(). The method onAliasSaveCallback() in /src/EventListener/DataContainer/TagListener.php:303 $aliasOptions = \Contao\PageModel::findBytype('root')->id ?? [];would change to $manager = $this->registry->get($dc->activeRecord->source); // Selected source
$aliasOptions = [
'locale' => $manager->getLocale(),
'validChars' => $manager->getValidChars()
];Pleas check out my last commit. I am not entirely sure, if this would be a breaking change – I don't think so… |
|
Thank you, looks good. I will have a look at it soon. |
| 'locale' => $manager->getLocale(), | ||
| 'validChars' => $manager->getValidChars() | ||
| ]; | ||
| $value = System::getContainer()->get('contao.slug')->generate($dc->activeRecord->name, $aliasOptions); |
There was a problem hiding this comment.
System::getContainer() should not be used. Use Depdendency Injection instead.
| 'locale' => $this->locale, | ||
| 'validChars' => $this->validChars | ||
| ]; | ||
| $alias = System::getContainer()->get('contao.slug')->generate($model->name, $aliasOptions); |
There was a problem hiding this comment.
System::getContainer() should not be used. Use Depdendency Injection instead.
In order to use tag aliases as a slug or URL query it makes sense to use contaos slug generator (defaults on ausi/slug-generator) instead of the StringUtil::generateAlias method.
"valid alias characters" and/or "language" of the root page will be used to generate the alias/slug:
'ASCII numbers and lowercase letters' and 'de' would convert "Äpfel" to "aepfel"