Hi,

I am using rules and a php code to create folders on the server on node creation. My input is the node title, which is names like "Tümer Alkoç" or "Tümer Ali Alkoç".

I need these inputs to be...
a) converted to all lower case.
b) spaces replaced with an underscore ( _ ).
c) accented characters to be latinized.
so the output would read "tumer_alkoc" and "tumer_ali_alkoc"

I believe if I can use one of the Transliteration module functions in my code properly I can achieve this. But I dont know how. I read the documentation and tried a couple of things but I am not a coder and couldnt find the right way to do it.

My php code that I want it to be transliterated is very simple as below.

<?php
$path
= "sites/default/files/$node->title";
mkdir($path);
?>

Can someone please help me how to do it....

Comments

Status:Active» Fixed

This should work, if not reopen (marking fixed will close this issue in 2 weeks).

<?php
$dir
= transliteration_clean_filename($node->title);
if (!
file_prepare_directory(file_build_uri($dir))){
 
drupal_mkdir(file_build_uri($dir));
}
?>

Note:
1) I have assumed that the sites default file storage is public and this resides in "sites/default/files"
2) The function transliteration_clean_filename() is from the Transliteration module, all other functions are core Drupal.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.