revolution
revolution copied to clipboard
Wrong static_elements_automate file names with non-latin chars
Bug report
Summary
Quick summary what's this issue about. MODX 2.8.4 generates wrong name for static file if template and maybe chunk) name has non-latin chars.
Maybe solution: translit support same as resource alias
Step to reproduce
How to reproduce the issue, including custom code if needed. When system setting static_elements_automate_templates is on and template named in Russian (i think any non-latin chars),
Observed behavior
How it behaved after following steps above.
Template name "Страницаfoo АБВbarДЕГha" static file named → "foo-barha.template.tpl"
Other example in screenshot:
Expected behavior
How it should behave after following steps above. With system settings:
- friendly_alias_translit_class = modx.translit.modTransliterate
- friendly_alias_translit = russian i expect template "Страницаfoo АБВbarДЕГha" static file named→ "stranicafoo-abvbardegha.template.tpl"
Environment
MODX version, apache/nginx and version, mysql version, browser, etc. Any relevant information. MODX 2.8.4
Currently the file name is generated entirely in Javascript with a regex that deletes every character not in \w
([A-Za-z0-9_]
) except for -
.
https://github.com/modxcms/revolution/blob/66e254d6d5d9370d5fcfa7cd73b705dace6e0d0e/manager/assets/modext/core/modx.js#L391-L393
As the transliteration for the resource alias happens in PHP, a similar transliteration for the static file name would require an Ajax-request (possibly using the existing modTranslitProcessor processor).
@halftrainedharry thanks for response!
In addition, It would also be great if the check took into account whether the file name for the static element was already filled in, and if it was filled in, then when the element page was first loaded in the admin panel, it did not apply the name processing algorithm, since the name may have been specified manually and not match to automatic rename rule!
And if you start renaming an element or set the "static" checkbox for the first time, then apply the renaming algorithm!
Now, on first page load manualy named static element instantly renamed ин MODX and this behavior with non-latin problem make static_elements_automate feature unusable at all even as temporary solution with manual corrections!