ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Live url title rendering fails after using multiple other seperators

December 15, 2008 3:43am

Subscribe [2]
  • #1 / Dec 15, 2008 3:43am

    Hey,
    My main url title seperator is ‘_’. When using another seperator in my entry title (ie. ‘.’ or ‘-’) on Publish Form the live url title generator isn’t working anymore.

    This problem occured after an upgrade from 1.6.1 to 1.6.6 (last week).

    See also attached screenshots.

    Moved to HowTo by Moderator

  • #2 / Dec 15, 2008 10:11am

    Pascal Kriete

    2589 posts

    It looks like it’s working OK.  The url title behavior was changed a little in 1.6.5.  Here’s what the changelog has to say about it:

    Modified URL title creation to allow dashes, underscores, and periods regardless of the separator preference, and to allow uppercase characters.

    Does this explain what you’re seeing?  When you access the url it generates, does it work?

  • #3 / Dec 15, 2008 11:21am

    Aha, the changelog shows the cause. Thanks.

    But now my url’s aren’t working anymore. Can I skip this feature someway?

  • #4 / Dec 15, 2008 11:25am

    Pascal Kriete

    2589 posts

    What do you mean by ‘not working anymore’?  Are you seeing 404s for existing entries?

  • #5 / Dec 15, 2008 12:15pm

    Indeed. Having another seperator in the url title causes 404s. This might be tackeled in the .htaccess because of we want clean url’s without special characters in it.

    Is it a possibility to disable this extra url title feature?

  • #6 / Dec 15, 2008 1:48pm

    Greg Aker

    6022 posts

    ralph:  Do you have a link to the site we can see?  I tried a url like:

    many….periods make my. page not…work. . .

    which gave me a url title of:

    many….periods_make_my._page_not…work._._

    And I’m not getting 404s.

    Are you running any extensions?

    Thanks,

    -greg

  • #7 / Dec 16, 2008 3:18am

    Unfortunatelly we don’t want to use periods in our url titles for SEO. A login for the site is also no issue.

    Maybe you can help, adjusting the JS for live-updating so the other seperators as ‘_’ are skipped.

    The current JS from the control panel is:

    /** ------------------------------------
            /**  Live URL Title Function
            /** -------------------------------------*/
            
            function liveUrlTitle()
            {
                var defaultTitle = '';
                var NewText = document.getElementById("title").value;
                
                if (defaultTitle != '')
                {
                    if (NewText.substr(0, defaultTitle.length) == defaultTitle)
                    {
                        NewText = NewText.substr(defaultTitle.length)
                    }    
                }
                
                NewText = NewText.toLowerCase();
                var separator = "_";
                    
                // Foreign Character Attempt
                
                var NewTextTemp = '';
                for(var pos=0; pos<NewText.length; pos++)
                {
                    var c = NewText.charCodeAt(pos);
                    
                    if (c >= 32 && c < 128)
                    {
                        NewTextTemp += NewText.charAt(pos);
                    }
                    else
                    {
                        if (c == '223') {NewTextTemp += 'ss'; continue;}
                    if (c == '224') {NewTextTemp += 'a'; continue;}
                    if (c == '225') {NewTextTemp += 'a'; continue;}
                    if (c == '226') {NewTextTemp += 'a'; continue;}
                    if (c == '229') {NewTextTemp += 'a'; continue;}
                    if (c == '227') {NewTextTemp += 'ae'; continue;}
                    if (c == '230') {NewTextTemp += 'ae'; continue;}
                    if (c == '228') {NewTextTemp += 'ae'; continue;}
                    if (c == '231') {NewTextTemp += 'c'; continue;}
                    if (c == '232') {NewTextTemp += 'e'; continue;}
                    if (c == '233') {NewTextTemp += 'e'; continue;}
                    if (c == '234') {NewTextTemp += 'e'; continue;}
                    if (c == '235') {NewTextTemp += 'e'; continue;}
                    if (c == '236') {NewTextTemp += 'i'; continue;}
                    if (c == '237') {NewTextTemp += 'i'; continue;}
                    if (c == '238') {NewTextTemp += 'i'; continue;}
                    if (c == '239') {NewTextTemp += 'i'; continue;}
                    if (c == '241') {NewTextTemp += 'n'; continue;}
                    if (c == '242') {NewTextTemp += 'o'; continue;}
                    if (c == '243') {NewTextTemp += 'o'; continue;}
                    if (c == '244') {NewTextTemp += 'o'; continue;}
                    if (c == '245') {NewTextTemp += 'o'; continue;}
                    if (c == '246') {NewTextTemp += 'oe'; continue;}
                    if (c == '249') {NewTextTemp += 'u'; continue;}
                    if (c == '250') {NewTextTemp += 'u'; continue;}
                    if (c == '251') {NewTextTemp += 'u'; continue;}
                    if (c == '252') {NewTextTemp += 'ue'; continue;}
                    if (c == '255') {NewTextTemp += 'y'; continue;}
                    if (c == '257') {NewTextTemp += 'aa'; continue;}
                    if (c == '269') {NewTextTemp += 'ch'; continue;}
                    if (c == '275') {NewTextTemp += 'ee'; continue;}
                    if (c == '291') {NewTextTemp += 'gj'; continue;}
                    if (c == '299') {NewTextTemp += 'ii'; continue;}
                    if (c == '311') {NewTextTemp += 'kj'; continue;}
                    if (c == '316') {NewTextTemp += 'lj'; continue;}
                    if (c == '326') {NewTextTemp += 'nj'; continue;}
                    if (c == '353') {NewTextTemp += 'sh'; continue;}
                    if (c == '363') {NewTextTemp += 'uu'; continue;}
                    if (c == '382') {NewTextTemp += 'zh'; continue;}
                    if (c == '256') {NewTextTemp += 'aa'; continue;}
                    if (c == '268') {NewTextTemp += 'ch'; continue;}
                    if (c == '274') {NewTextTemp += 'ee'; continue;}
                    if (c == '290') {NewTextTemp += 'gj'; continue;}
                    if (c == '298') {NewTextTemp += 'ii'; continue;}
                    if (c == '310') {NewTextTemp += 'kj'; continue;}
                    if (c == '315') {NewTextTemp += 'lj'; continue;}
                    if (c == '325') {NewTextTemp += 'nj'; continue;}
                    if (c == '352') {NewTextTemp += 'sh'; continue;}
                    if (c == '362') {NewTextTemp += 'uu'; continue;}
                    if (c == '381') {NewTextTemp += 'zh'; continue;}
                    
                    }
                }
                
                var multiReg = new RegExp(separator + '{2,}', 'g');
                
                NewText = NewTextTemp;
                
                NewText = NewText.replace('/<(.*?)>/g', '');
                NewText = NewText.replace(/\s+/g, separator);
                NewText = NewText.replace(/\//g, separator);
                NewText = NewText.replace(/[^a-z0-9\-\._]/g,'');
                NewText = NewText.replace(/\+/g, separator);
                NewText = NewText.replace(multiReg, separator);
                NewText = NewText.replace('.', separator);
                NewText = NewText.replace(/-$/g,'');
                NewText = NewText.replace(/_$/g,'');
                NewText = NewText.replace(/^_/g,'');
                NewText = NewText.replace(/^-/g,'');
                NewText = NewText.replace(/\.+$/g,'');
                
                if (document.getElementById("url_title"))
                {
                    document.getElementById("url_title").value = "" + NewText;            
                }
                else
                {
                    document.forms['entryform'].elements['url_title'].value = "" + NewText; 
                }        
            }
  • #8 / Dec 16, 2008 11:41am

    Sue Crocker

    26054 posts

    Ralph, this thread has now become more of a Howto instead of a technical support thread. So moving to HowTo.

  • #9 / Dec 16, 2008 12:42pm

    Okido. I believe it could be an howto if someone can help me with the solution…

  • #10 / Dec 17, 2008 2:33am

    I hope someone can help me on this one, because it’s a quite nasty problem now for all publishers on the site.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases