-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Is your feature request related to a problem? Please describe.
When addons such as DataGrab or Smart Importer create new entries, they have to handle the logic of creating a URL title that EE thinks is valid. Also if the title is not unique. If this validation fails, the entry is rejected. This behavior changed between v2 and v3.
Describe the solution you'd like
EE should have a method in the Entries model to create a valid, unique, URL title when validation fails.
Describe alternatives you've considered
I created an extension that created a random URL title (since I don't use them). Could create an extension from the function below. Could modify the core, or addons to add this function.
Teachability, Documentation, Adoption, Migration Strategy
This should reduce documentation.
For reference, I think this is the EE v2 URL title method /system/codeigniter/system/helpers/url_helper.php
if ( ! function_exists('url_title'))
{
function url_title($str, $separator = 'dash', $lowercase = FALSE)
{
if ($separator == 'dash')
{
$search = '_';
$replace = '-';
}
else
{
$search = '-';
$replace = '_';
}
$trans = array(
'&\#\d+?;' => '',
'&\S+?;' => '',
'\s+' => $replace,
'[^a-z0-9\-\._]' => '',
$replace.'+' => $replace,
$replace.'$' => $replace,
'^'.$replace => $replace,
'\.+$' => ''
);
$str = strip_tags($str);
foreach ($trans as $key => $val)
{
$str = preg_replace("#".$key."#i", $val, $str);
}
if ($lowercase === TRUE)
{
$str = strtolower($str);
}
return trim(stripslashes($str));
}
}