Recent Topics

1 Jan 30, 2015 15:17    

I suspect this bug is in newer versions of the code too.

Essentially a new feature was introduced in version 4 "Automatic post slugs will only include 5 words by default -- but you can always manually enter your own and longer slug"

When creating a new blog post you enter a title. The title updates the slug as you type. So if my title is "This is a very long wordy title" then the slug is updated to "This is a very long wordy title", but when I save the blog it is mangled to "this-is-a-very-long". I then have to go back and update the slug and delete the old one. I could edit the slug after I have typed the title manually replacing all the spaces and punctuation with minuses, but this is a pain and I sometimes forget.

I suppose the bug here is that the JavaScript fills the slug automatically with incorrect data that you are supposed to change later rather than filling it up with correct data that you don't have to change. I also disagree with your magic number of 5 words as I thing that Google uses all of them along with all the stuff in the page for its SEO calculation.

So can we have a backend option like $g_slug_word_length defaulting to 5 but zero means keep all my words. As an easy workaround (for me) I have implemented it in JavaScript on the frontend. It was over complicated by the slug_changed option so I've stripped it all out!

Here is the diff:

--- inc/items/model/_item.funcs-original.php    2015-01-30 13:24:02.483624200 +0000
+++ inc/items/model/_item.funcs.php     2015-01-30 13:23:28.442799192 +0000
@@ -2171,19 +2171,14 @@
        <script type="text/javascript">
-               var slug_changed = false;
                jQuery( '#post_title' ).keyup( function()
-                       if(!slug_changed)
-                       {
-                               jQuery( '#post_urltitle' ).val( jQuery( '#post_title' ).val() );
-                       }
-               } );
-               jQuery( '#post_urltitle' ).change( function()
-               {
-                       slug_changed = true;
-                       jQuery( '[name=slug_changed]' ).val( 1 );
+                               var t_title = jQuery( '#post_title' ).val().toLowerCase();
+                               t_title = t_title.replace(/[^a-z0-9]/g, "-");
+                               t_title = t_title.replace("--", "-");
+                               t_title = t_title.replace(/^-/, "");
+                               t_title = t_title.replace(/-$/, "");
+                               jQuery( '#post_urltitle' ).val( t_title );
                } );

3 Apr 15, 2015 05:44

Maybe a good idea would be to use the maxlength attribute on the field in which you can enter your own slug.

4 Apr 15, 2015 23:14

@zooplah wrote:

Maybe a good idea would be to use the maxlength attribute on the field in which you can enter your own slug.

I'm afraid it's not an option because we can use that field to set several slugs (separated by commas) for the same post. In addition, the slugs' length is based on words instead of characters.

Regards !

Form is loading...