Sorry if this has been asked before, but I’d like to limit the length of the automatically-generated url title. The writer on the blog I installed tends to write huge long titles and the URLs get a bit silly.
Is there a setting to indicate how long they should be?
Not if you’re talking about auto links and addresses just pasted in along with the rest of the text. I would kindly point him/her to pMcode, and make sure that he has the formatting buttons visible in his publish screen to make Link adding painless.
No, I’m talking about the URL of the actual post that is automatically generated. So, for example, a post titled:
Here’s a title with quite possibly the longest url string ever written. Well, maybe not, but close.
is automatically given the url:
http://www.website.com/index.php/weblog/comments/a_title_with_75_characters_making_it_quite_possibly_the_longest_url_string_ever/
Which, as you’ll admit, is a bit silly. I’d like to limit this as I can’t depend on the author(s) to remember to shorten the urls.
I could be wrong but I don’t think that there is a setting for that anywhere. Would probably require a hack on the code to enable you to do that or maybe even a change in the max length on the database table.
Maybe an easier thing to do would be :
If the author really wants to use a long title then allow them to but use a custom field for it. That way they would put a shortened version in the {title} field and then whatever they like in the custom field. You could then spit out the custom field but make the URL reference the {title} field.
I know it means a bit more work on their behalf but if that is really what they want then I don’t think there is another way I’m afraid. I could definitely be wrong though and someone else may be able to provide a solution to your problem.
And more work on my behalf. Limiting the database field wouldn’t make sense to me, because the bit before the title part of the url could be a variety of lengths. I’m perfectly happy hacking the code. I assume it’s a simple numerical limit somewhere if someone could just point me to it?
I can’t control the writers and can’t trust them to remember to shorten the urls.
Out of interest, why does it have such a large number? It obviously limits the length, because it truncated that long title. But it is, in my opinion, an excessively large number of characters for a url…
Ah, hm. Well, you’d probably have to hack the back end. It’s a javascript function that auto-types the url_title field for you while you write the title. Truncating it to a set number of characters could have at least one major drawback: it would create URLs that really don’t give meaning to the entry, which hurts both usability and potentially, search engine rankings. But, you could probably do it if training them on url_titles isn’t an option. You’ll need to know js, and change the Live URL Title function in cp.publish.php. I highly, highly dis-recommend this. I think the effort will be less and the payoff greater to simply tell them to use shorter URL titles that still convey meaning. A brief explanation of how it impacts search engine results is generally enough to motivate authors to pay attention.
OK, well, I’ll give it a go and use the hack as a backup plan. Of course, the site is private, password-protected and not spiderable, so the search engins thing is immaterial and not a good stick to beat them with. The biggest issue is that members sending urls to other members (of which there are many) in email messages end up getting it split over two lines and essentially makes the links unusable.
But seriously (and out of interest), don’t you think that url I quoted above is excessively long?
Now, I think I’d better edit that url string out now, since I know these forums are public and spiderable. Don’t really want anyone running across it by accident.
You run into even longer titles for medical articles. They look more like paragraphs.
Another downside to using the {title} field for long headings is the Edit screen/page/list gets really messy. The width of the Title cell is pretty narrow.
I rarely set up a site where I use the {title} as the “headline”. I almost always set a custom field for that and tell the writers the {title} field is for a quick article identifier/reference (card catalog type of thing).
I definitely wouldn’t hack as then you have to re-hack with every update (been there done that).
As a quick update. I haven’t actually checked this yet but I think that it might work. Not currently able to access EE so can’t say. I think that you can actually (after typing in the title) change the auto generated title to anything that you like. I could be wrong because as I say I am not in front of EE at the moment. There may be some caveats to doing that though, I don’t know. Maybe someone could pipe up and let us know??
Also, unfortunately this would also mean that either the author would have to do this which they may moan about doing or you would have to go in on each new entry and change them yourself.
Just an idea though. Sorry my first idea didn’t help.
Yes, you can type whatever you want in the url_title, but the problem yolise has is that the authors aren’t likely to pay attention to instructions to shorten it before submitting an entry.
Be careful though. Personally I think that if you are the admin of a site and you are letting people submit to it then they should really follow your suggestions on posting. Not really too much to ask I don’t think. You could always delete their posts if they are too long.