Hi there,
I’m creating my first website with ModX. Things have been going pretty well so far but I’ve hit a bit of a problem with the Search Engine Friendly URLS. If my article title has a percentage in it (which is quite common for this site), the search engine friendly alias will cause a broken link as %’s are not stripped.
Is this something that I’ve done wrong and is it an issue with this release?
Thanks in advance for any advice.
Roan
System info
-----------------------
Linux Apache Server
PHP Version 4.4.4
Mod X Versnio 0.9
you can use this plugin whith a little retouch to sweet your needs, but remember the url passed change from % to _
hi
/* <? /*
* CustomAliases by Brett @ The Man Can!
* Version 0.86, 2006-09-23
* Based very heaviliy on AutomaticLongtitle code by Mitch
* "Accented to Non-Accented Characters" from http://weblogtoolscollection.com/
*/
// CONFIGURATION:
// Change the below line to how you’d like your alias to generate.
// IMPORTANT: Make sure you change the second "if" statement below if you use different fields.
$alias_new = $_POST[’longtitle’].’.’.$_POST[’pagetitle’];
$e = &$modx->Event;
// Only on this event
if ($e->name == ’OnDocFormSave’)
{
// Check if the alias is empty
if ($_POST[’alias’] == ’’ && $_POST[’longtitle’] != ’’)
{
$alias_new = str_replace(’&’,’and’,$alias_new);
$alias_new = str_replace("’","",$alias_new);
// Convert accented characters to their non-accented counterparts.
$alias_new = strtr($alias_new,
" ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ",
"-SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy");
$alias_new = str_replace(’--’,"-",$alias_new);
$alias_new = str_replace(’%’,"_",$alias_new);
$alias_new = strtolower($alias_new);
$alias_new = urlencode($alias_new);
$fields = array(’alias’ => $alias_new);
$table = $modx->getFullTableName(’site_content’);
// Update the database
$rows_affected = $modx->db->update(
$fields,
$table,
"id = {$e->params[’id’]}"
);
// Generate an error if the DB was not updated
if(!$rows_affected)
{
$modx->event->alert("CustomAlias: An error occured when saving the alias.");
}
}
}
I saw this plugin actually, and tried to install it but to no avail. I checked the box to activate the plugin OnDocFormSave but no luck. Is there anythig else I need to do. Turn off friendly alias’ in the system config?
Also, does this plugin require a specific version of ModX?
Thanks for all your help.
Roan
you need to reedit the pages whith % for save the correct alias