14

My client needs longer titles/URL titles/Structure url titles, but there is no add-on available with this specific functionality. I already know about these add-ons, but they don't do what I need. A support request with Title Master is already filed, it extends titles in Structure, but the url_title is still cut-off at the shorter length, all three components needed to be extended.

So I need to hack the core, but I'm not sure which files I need to modify. So far, I've found these 2 files:

  • /system/expressionengine/controllers/cp/content_publish.php, lines 2279 & 2291
  • /system/expressionengine/third-party/structure/tab.structure.php, line 156

Those files seem to update the "maxlength" parameter on the HTML for the 3 title input fields.

And I've found these database tables:

  • exp_channel_titles > title
  • exp_channel_titles > url_title
  • exp_structure_listings > uri

So I think I just need to change a few more files, but I don't know where they are:

  • Javascript file that controls the URL Title auto-fill on the publish page.
  • Javascript file that controls the Structure URL Title auto-fill on the publish page.
  • Structure Page URL database column.

Does anybody know where these are, and possibly what line number I need to edit? Am I forgetting anything? Thanks.

5 Answers 5

11

I've had the need to do this a number of times, particularly on sites that have press releases. For some reason, press release titles can be insanely long. This is all we ever have to do:

In system/expressionengine/controllers/cp/content_publish.php, appx line 2279, change this to what you desire:

'title' => array(
  ...
  'field_maxl' => 255
),

If you need to alter the URL title too, look for the same thing in the url_title array below it, around line 2292:

'url_title' => array(
  ...
  'field_maxl' => 75
),

The only other thing we do is alter the database column in exp_channel_titles accordingly.

ALter the DB fields to match your max length

Unless I'm missing something, that's all we've ever needed to do. As for updating this to work on Structure titles, I'm sure the method is similar, but I don't use Structure very often so I can't really speak to it. Sounds like you're on the right path with where you're looking. I'm not sure why you would need to alter any of the JavaScript around the title fields.

As always, you should document your core hacks, no matter how simple they are.

4
  • 2
    This change worked for you without changing the maxlength attribute in the view files? Even if the DB length is changed, that maxlength needs to be changed (its hard coded) or else you just can't type past 100 characters. Commented Jan 3, 2013 at 17:15
  • I don't recall having to do that (EE 2.5.3). Commented Jan 3, 2013 at 20:06
  • @Brian, the maxlength attribute does not seem to be hardcoded in 2.5.3, and will use whatever value is entered for field_maxl in the url_title and title arrays that Ryan mentioned. But I think there might be another step needed (not sure what) to allow for the url_title to go past 75 chars, though.
    – Alex Kendrick
    Commented Jan 3, 2013 at 20:20
  • There's definitely something keeping the URL Title and Structure URL fields from being auto-filled to the full length. I changed the field_maxl variables as you suggested - the maxlength parameters on the HTML input reflects that change, and you can manually type the longer title, but the autofill stops at the original, shorter length. The weird thing is my web inspector shows no event listeners on those input fields, but I could be doing it wrong.
    – kmgdev
    Commented Jan 7, 2013 at 16:50
11

Note: The Title Master add-on should take care of all of this, but if you can't use that for whatever reason, here is the procedure for the hack:

Update 10/10/14: Title Master appears to be abandonware at this point.

This works as of EE 2.9

Always back up your files and database before hacking the core!

Native EE Titles & URL Titles

  • /system/expressionengine/controllers/cp/content_publish.php:

    $deft_fields = array(
        'title'         => array(
            /* ... */
            'field_maxl'            => 100 // update to desired max title length
        ),
        'url_title'     => array(
            /* ... */
            'field_maxl'            => 75 // update to desired max url title length
        ),
    
        /* ... */
    

    This updates the maxlength attribute on the input fields so you can type longer titles/URL titles.

  • /system/expressionengine/libraries/Api.php:

    $url_title = substr($url_title, 0, 75); // update to desired max url title length
    
    /* ... */
    
    if (strlen($url_title) > 70) // update to desired max url title length minus 5
    {
        $url_title = substr($url_title, 0, 70); // update to desired max url title length minus 5
    
    /* ... */
    
    if (strlen($url_title.$url_title_suffix) > 75) // update to desired max url title length
    

    This updates the function that actually publishes the entry to the database to allow a longer URL title.

  • /themes/javascript/compressed/jquery/plugins/ee_url_title.js:

    Near the end of the code, find .val(a.substring(0,75)) and update "75" to your desired URL title length. This allows the URL title to autofill to the correct length.

  • Go into the database and update the length of the following columns:

    • exp_channel_titles.title
    • exp_channel_titles.url_title

    This will allow your longer titles to be stored correctly in the database columns.

Structure URL Titles

  • /system/expressionengine/third_party/structure/tab.structure.php, inside the publish_tabs() method, in the "Field: Page URI/Slug" section:

    $settings[] = array(
        /* ... */
        'field_maxl'            => 100, // update to your desired max url title length
    
        /* ... */
    

    This updates the maxlength attribute in the input field.

  • Update the length of this database column:

    • exp_structure_listings.uri

    This allows for longer URL titles on Structure listing-type entries. Page-type entry URL titles are encrypted and stored in the exp_sites table, and I do not believe you need to make any modifications there for longer URL titles to work.

Document, Document, Document!

Be sure to document the changes you made so they don't get overwritten when you update EE. It's also just the professional thing to do. If you leave the project and another developer has to take your place and figure out what you did, good documentation will keep them from cursing your black soul. I recommend Focus Lab's Dev Docs module.

1
  • 1
    On EE v2.7.3 the content publish line nnumbers are 2172 and 2184. Commented Feb 20, 2014 at 22:20
5

I'm not certain why Title Master would be insufficient for your needs. It handles increasing title length, url_title length, and works with Structure. Maybe if you state what it doesn't do that you need, that could help in identifying an alternative.

Otherwise, if you're going to hack, I think you've hit all the main spots, obviously making sure the database will handle the new size is also necessary, but it looks like you've got that covered. We hacked once for a client, in EE1, but the areas were similar, except no Structure.

9
  • 1
    Do you really need the url titles to be the same length as the title? Usually in our case the client wants a 100+ length title, but a 100+ length url slug is kind of excessive... it can be shortened to something sane manually. Commented Jan 3, 2013 at 16:25
  • I asked for clarification, because you didn't link to or state 'why' it didn't meet your needs in the original post. I'll edit the original request for you. Also, we've never edit the Javascript files for this to work, client manually entered longer url_title, if needed. Commented Jan 3, 2013 at 17:15
  • @Brian Litzinger My client is quite adamant about the URL titles matching the entry titles, "because that's what Joomla used to do".
    – kmgdev
    Commented Jan 3, 2013 at 17:40
  • 1
    @StuartMcCoy Currently there's a bug with the native URL Title auto-fill functionality. The developer has known about it for quite some time, but has offered no status updates on a fix.
    – kmgdev
    Commented Jan 3, 2013 at 20:16
  • 1
    There was a bug but he recently updated Title Master which seems to have fixed the issue. I'm currently using it on a site I'm developing and it works fine. Commented Jan 3, 2013 at 20:42
1

I ran into the need for longer titles (eg. scientific paper titles), and (shameless plug) Zenbu Studio's Kyara module did the trick. Structure url titles are not supported as of this writing, however.

1
  • If it doesn't support Structure, it's not going to work for me.
    – kmgdev
    Commented Jan 3, 2013 at 0:54
1

This plugin doesn't support Structure i don't think, but it still works for making titles longer. http://devot-ee.com/add-ons/mx-title-control. The Title Master plugin looks to be no longer supported.

Just adding this info for future searchers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.