Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Latest Forum Posts - slight change
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Latest Forum Posts - slight change

 Post Reply Post Reply
Author
Stevoh View Drop Down
Newbie
Newbie


Joined: 15 January 2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Stevoh Quote  Post ReplyReply Direct Link To This Post Topic: Latest Forum Posts - slight change
    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
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
Stevoh View Drop Down
Newbie
Newbie


Joined: 15 January 2013
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote Stevoh Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.