Help - Search - Members - Calendar
Full Version: Trimming URL's in Comments?
Movable Type Community Forum > Additional Resources > Tips and Tricks
jmevius
Is there a way to trim an incoming url in the MTCommentBody tag? Currently, if someone leaves a url in my comments, it is autolinked. If the url is long like:

http://this.is.a/really_long_url/with_many...t_want_that.php

I would like to break it to the first 40 characters, plus a few periods, like so:

http://this.is.a/really_long_url/with_ma..

Any ideas? I would still want it linked to the original (long) destination.

On preview: It appears that the forum software itself knows how.
medic119
Not that I know of, but there are tag to trim excerpts etc.

Try the remove_html="1" tag to turn the URL into a text link. It will remove the url from the link text leaving just the text behind. I use it in my "recent Comments."

The other tag is Trim_to="xx" where xx is a numeral. That will trim excerpts to whatever length you want.

In my Recent comments I use trim_to="50" to trim the comment excerpts to only 50 characters.

The code would look something like
<MTCommentBody trim_to="50" remove_html="1">

Don't know if thats exactly what you are lookign for, but its the best answer I have using the built in MT functions.
girlie
nicer autolinked URLs in comments
jmevius
Thanks for everyone who wrote in suggestions. This is the anwer I was dying for the whole time.
girlie
Which is the topic I referenced in my entry linked above. wink.gif
jmevius
Sorry. I misinterpreted your writeup as saying it would extract the page title, kinda like link title capability.

Thanks.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.