Print Page | Close Window

Shrinking links in forum posts

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=20541
Printed Date: 29 March 2026 at 1:24pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Shrinking links in forum posts
Posted By: Mattblack
Subject: Shrinking links in forum posts
Date Posted: 04 July 2006 at 8:13pm
Hi,
 
I have a forum system that I have made.  Users are able to submit data to a database, which is then pulled from the database in a posts page.
 
Each post in the table is in its own table/cell within the posts page.
 
If a user submits a link that is excessively long, it stretches the table (as do pictures).
 
Is there any way I can only show the first x characters of the link, whilst keeping the URL of the link intact???

In the database, the data will look as follows...
<A title=LINK href="link_url_here">LINK</A>
 
How can I only show x characters from the LINK part before the </A> ???
 
Im tearing my hair out with it.  Its the same for pictures posted that are too big for the table column/cell width.
 
What am I best to do?
 
Really appreciate any help on this.
 
Matt



Replies:
Posted By: dpyers
Date Posted: 04 July 2006 at 11:25pm
Unless I'm missing something obvious, I'd use Instr to search first for a <A (lcase), and then for the next >. After that I'd use Instr to find the position of the first </A and then check the length between the first > after <A and the </A. If greater than some value, use Mid to replace the string with something like "LINK:timestamp". or you can use Rtrim and Mid to shring the original string.

There's an example of how to pull data from between 2 character strings here - http://new2asp.com/Section_Files/PullStrings/PullStrings.asp - http://new2asp.com/Section_Files/PullStrings/PullStrings.asp

You'd be better off to do it when the info is added to the db. That way you only do it once, not everytime the page is displayed.

IIRC, ASPJpeg ca resize images it uploads and can also determine the size of the image if you just want to handle it by adding height and width attributes to the image tag. It'll beat your server to death though. There's really no elegant way to do this. Fluid instead of fixed layout is the only really viable solurion other than telling your users not to do it.


-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mattblack
Date Posted: 09 July 2006 at 12:24am
thanks mate, ill work on trying this.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net