I’d like for FURLS to have underscores instead of dashes, and to lowercase all alias names or page names where creating URIs. Can anyone tell me where or how to do this, what class or modx core section the method that creates the FURL from the alias name is located?
Cheers and thanks
Steve
-
MODX Staff
- 12,272 Posts
If you mean automatically creating from the page title, then that’s handled by /manager/processors/save_content.processor.php
Otherwise, you can manually create your aliases however you’d like.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Thanks, ryan - I’ll dig around in there. I have about 600 pages where the alias needs to conform to a lower-case, underscore standard, and it would simply be easier to add a strngtolower() and str_replace() to the $alias var than go in by hand and touch all of those aliases - which brings up another pooint - it’d be nice to see an option in future modx releases that allowed to user to choose the illeagal character and whitespace replacement character with several options, or one of their choosing, as well as the option to lower-case the created URL (if one decides to have modx create the alias from the page title).
Thanks again,
’
Steve
Ryan,
It appears as if the stripAlias() is the function that modifies the alias or page title for FURL creation, correct? I’ve made some adjustments, but they seem to be having no effect. In fact, for auto-alias creation, iit also appears that strtolower() is already used, but of course, I still get UC charcters in my FURLs - am I in the correct function?
S
-
MODX Staff
- 12,272 Posts
Existing pages will need to be resaved after making any changes you need to make.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Oh, I see- the application creates the urls and the saves them to the DB in modx_site_content.alias - for anyone who reads this, this can be solved by perfroming this action on that column....backup modx_site_content prior to doing this. Then, go to line 575 in save_content.processor.php, and alter the stripAlias() function: (below the sql) -- perform these at your own risk!!
// sql ////////////////////////////////////////////////
UPDATE modx_site_content
SET alias=( LOWER ( REPLACE ( alias, ’-’,’_’ ) ) );
///////////////////////////////////////////////////////
function stripAlias($alias) {
global $modx;
if(strtoupper($modx->config[’etomite_charset’])==’UTF-8’) $alias = utf8_decode($alias);
$alias = strtr($alias, array(chr(196) => ’Ae’, chr(214) => ’Oe’, chr(220) => ’Ue’, chr(228) => ’ae’, chr(246) => ’oe’, chr(252) => ’ue’, chr(223) => ’ss’));
$alias = strip_tags($alias);
$alias = strtolower($alias);
$alias = preg_replace(’/&.+?;/’, ’’, $alias); // kill entities
$alias = preg_replace(’/[^\.%A-Za-z0-9 _-]/’, ’’, $alias);
$alias = preg_replace(’/\s+/’, ’_’, $alias);
$alias = preg_replace(’|-+|’, ’_’, $alias);
$alias = trim($alias, ’-’);
return $alias;
}
steve