Print Page | Close Window

Latest Forum Posts - slight change

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=30633
Printed Date: 28 March 2026 at 5:52am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Latest Forum Posts - slight change
Posted By: Stevoh
Subject: Latest Forum Posts - slight change
Date Posted: 16 January 2013 at 12:03am
Hi,

I'm trying to add recent forum posts to the main page of a website using an iframe that calls an asp file.

The recent_forum_posts.asp file helps, but if I want to display the contents of the post itself then line 90 in the file needs to be uncommented.

However this causes the entire post contents to be displayed. For long posts this is too much information to display on the front page of a website.

Is there some sort of coding that I could insert into the recent_forum_posts.asp file that would allow me to truncate the content after a predefined number of characters? For example, set a value at 150 to have the first 150 characters of the posting display, followed by a <more> hyperlink to the post itself.

Thanks in advance
Steve



Replies:
Posted By: Scotty32
Date Posted: 16 January 2013 at 8:31pm
This is what I usually use and might be of help, though you will need to adapt it for your needs.

<%
    if Len(strPostMessage) >150 Then
        strPostMessage = Mid(strPostMessage,1,147) & "..."
    End If
%>


It will trim down the post to the first 147 characters and add "..." to the end (without quotes) to indicate that it has been trimmed down, if you dont want this just remove that part of the code.


-------------
S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins

For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .


Posted By: Stevoh
Date Posted: 23 January 2013 at 12:30am
Thanks Scotty,

I played around with it and was successful in truncating the message.

However, since the RSS childnode that holds the content of the posting also contains a bunch of other information (author, posting date, lots of html coding, etc) I found it not to be as reliable as I would like.

For example, the truncating method considers all the html codes as part of the message, so the truncation could occur right in the middle of a html tag. This also makes it difficult to predict how many characters of the actual posting will get displayed, as the number of characters taken up by the html tags is always a variable. It is also problematic if there is an image or YouTube video inserted into the posting.

This means the content and format of the posting can affect the final result.....sometimes it works fine, other times it returns a server error.



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