-
-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use contao.slug to generate tag alias #36
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"