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
Slug conversion to ASCII does not work when using custom title #2096
Comments
What version of Craft are you seeing this in? |
@brandonkelly I am using Craft CMS 2.6.2989 |
Just tested and I’m not able to reproduce on 2.6.2997. Can you try updating and see if that helps? The only thing I can think of is, maybe you enabled the |
@brandonkelly I am unable to test in the most recent version at the moment.. I have following in my general.php: |
|
@brandonkelly But this conversion from ä => ae and such did work before... Where do I control these character conversions? I want that my characters (often used in German language) äöüßÄÖÜ to convert to the corresponding ASCII letters.. |
@brandonkelly It seems that the logic from the |
@steveooo9 Tested both and both were converting correctly for me. Possible you added that config setting after the initial entry had been saved? |
There are two places that config setting is taken into account – in the CP JavaScript, when auto-populating the Slug value as you type in the Title field, and in the PHP when the entry is being saved. |
I'm not able to reproduce this on a stock Craft install, either. The |
@takobell Can it be that when using auto title via |
@steveooo9 Try this for me… open up craft/app/helpers/ElementHelper.php and replace your public static function setValidSlug(BaseElementModel $element)
{
$slug = $element->slug;
if (!$slug)
{
// Create a slug for them, based on the element's title.
// Replace periods, underscores, and hyphens with spaces so they get separated with the slugWordSeparator
// to mimic the default JavaScript-based slug generation.
$slug = str_replace(array('.', '_', '-'), ' ', $element->title);
// Enforce the limitAutoSlugsToAscii config setting
if (craft()->config->get('limitAutoSlugsToAscii'))
{
if (!craft()->config->get('allowUppercaseInSlug'))
{
// Do this now because our ASCII character mappings are lowercase only.
$slug = mb_strtolower($slug);
}
$slug = StringHelper::asciiString($slug);
}
}
$element->slug = static::createSlug($slug);
} Then clear out the auto-generated entry slug and try re-saving it. |
@brandonkelly Yep, this works great! Great fix! |
Awesome, thanks for letting me know. We’ll get that fix into the next release. |
@brandonkelly Great! |
Description
Auto-generate slugs (conversion from ä-ö-ü-ß => ae-oe-ue-ss) from a title does work, but defining a title like
{entryField.first().title}
doesn't convert the äüöß, but removes them.Steps to reproduce
{entryField.first().title}
If you can't reproduce, I am glad to help in any further bugfixing!
The text was updated successfully, but these errors were encountered: