Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - MOD: Latest Forum Posts for your website
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

MOD: Latest Forum Posts for your website

 Post Reply Post Reply Page  <1234 5>
Author
wizmike View Drop Down
Newbie
Newbie


Joined: 27 June 2006
Location: Australia
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote wizmike Quote  Post ReplyReply Direct Link To This Post Posted: 04 July 2006 at 2:21am
I now have maddog's original code working with Access. Check the sql statements very (very) carefully
 
I included the file on the home page of a web site. All OK.
 
But... It returns the last ten posts alright but here is the but...
If the last ten posts are all within the same topic, you get ten identical links
 
Mmmm. More work needed methinks on this.
I will keep plugging away.
 
Anyone else working on this?
 
edit:
I tried:
strSQL = "SELECT DISTINCT Top " & intLastestPostsTotal & " "
strSQL = strSQL & "tblThread.Topic_ID, tblForum.Forum_name etc.
 
The idea being that DISTINCT would work on tblThread.Topic_ID
But it didnt, I still got multiple Topic_IDs
 
DISTINCT may be the way though?
 
But DISTINCT needs to work its stuff only on "Topic_ID"
 
.
 


Edited by wizmike - 04 July 2006 at 3:15pm
Back to Top
aliceaod View Drop Down
Newbie
Newbie


Joined: 24 February 2006
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote aliceaod Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2006 at 1:48am
I get this error when I access the main forum. Not sure what I did wrong...
 
 

Active Server Pages error 'ASP 0126'

Include file not found

/forum/common.asp, line 1

The include file 'includes/global_variables_inc.asp' was not found.

Back to Top
wizmike View Drop Down
Newbie
Newbie


Joined: 27 June 2006
Location: Australia
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote wizmike Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2006 at 4:54am

Based on the idea by "MadDog" at:
http://b2.iportalx.net/forum_posts.asp?TID=88&PID=797
- - - - - - - - - - - - - - -

To display the last xx posts on any page within the website outside the forum.
I tried other mods but some could not be placed on ANY page within the site and/or would show last 10 posts OK but if the last 10 were within the same topic then I got 10 lines all pointing to the same topic!
NOTE: code is for MS Access. See page above for other databases.

"last_ten_posts.asp" placed in the forum directory

<%
' to be used as an include on another page, like
' <!--#include virtual = "/forum/last_ten_posts.asp" -->
%>
<p style="text-align : left; font-size : 80%;color:#800000;">
 Latest 10 Forum Posts
<br />
<%
Dim strLastestPostsModForumPath
Dim intLastestPostsTotal
Dim intCharacters
Dim strLastestPostsModCon
Dim adoCon
Dim rsAll
Dim strSQL
Dim intLoopCounter
Dim strTID
Dim strSubject
Dim strPID

'The absolute path to the forum
strLastestPostsModForumPath = "/forum/"

'How many new topics to show
intLastestPostsTotal = 10

'How many characters to show from the Topic title?
intCharacters = 18

'Database connection
'Default connection - adjust to suit
strLastestPostsModCon = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("/forum/database/wwForum.mdb")

Set adoCon = Server.CreateObject("ADODB.Connection")

adoCon.Open strLastestPostsModCon

Set rsAll = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT TOP " & intLastestPostsTotal & " "
strSQL = strSQL & " Topic_ID, Subject, Last_thread_ID "
strSQL = strSQL & " FROM tblTopic "
strSQL = strSQL & "ORDER BY Last_Thread_ID DESC;"

'open the connection
rsAll.Open strSQL, adoCon

'if there are records put into an array then close the connection
If NOT rsAll.EOF Then strArrayAll = rsAll.getRows()
rsAll.Close
Set rsAll = Nothing
adoCon.Close
Set adoCon = Nothing

'Loop through the array of forum posts
For intLoopCounter = 0 TO UBound(strArrayAll, 2)
  'strArrayAll array lookup table
  '0 = Topic_ID
  '1 = Subject
  '2 = Last_thread_ID
  strTID = strArrayAll(0, intLoopCounter)
  strSubject = strArrayAll(1, intLoopCounter)
  strPID = strArrayAll(2, intLoopCounter)

 'if someone uses a single quote in the title like: Where's
 'the quote is stored as &#039; which is normally Ok unless the line gets truncated.
 'I had a line truncated at 18 characters which left the & showing at the end of the line :-)
 'so lets replace it with a single quote. May need to do the same for other "odd" characters. What about a double quote? etc.
  strSubject = replace(strSubject, "&#039;", "'")
 
  'Crop the subject down to "intCharacters"
  If Len(strSubject) > intCharacters then strSubject = Left(strSubject,intCharacters) & "..."

  Response.Write "<a href=""" & strLastestPostsModForumPath & "forum_posts.asp?TID=" & strTID & "&" & "PID=" & strPID & "#" & strPID & """>" & strSubject & "</a><br />" & vbcrlf

  Next
%>
</p>



Edited by wizmike - 30 July 2006 at 3:00am
Back to Top
Exis View Drop Down
Groupie
Groupie
Avatar

Joined: 24 October 2002
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote Exis Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2006 at 3:21pm
You did it!

Well done! Working great.

Be sure to add this to the MOD index so others can find it easily.

Thanks
Back to Top
ppkppk View Drop Down
Groupie
Groupie
Avatar

Joined: 24 November 2003
Location: United Kingdom
Status: Offline
Points: 43
Post Options Post Options   Thanks (0) Thanks(0)   Quote ppkppk Quote  Post ReplyReply Direct Link To This Post Posted: 30 July 2006 at 5:43am
Yep worked for me also, thanks WizMike
Back to Top
zeli View Drop Down
Newbie
Newbie


Joined: 06 August 2006
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeli Quote  Post ReplyReply Direct Link To This Post Posted: 10 August 2006 at 1:34am
I really like this idea, since I usually update our homepage with discussion topics manually. As I don't have time to do this, it gets outdated very fast:

http://www.circleoftrust.org/

I'm not sure I followed the instructions correctly.

I created a blank "last_ten_posts.asp" in my forum directory

then I copied the code in wizmike's post because I only want to display 4 topics and his code seems like it will let me customize that.

and then I saved and I have a "last_ten_posts.asp" in my forum directory.

Now my question is, how do I put that into my homepage?

Back to Top
wizmike View Drop Down
Newbie
Newbie


Joined: 27 June 2006
Location: Australia
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote wizmike Quote  Post ReplyReply Direct Link To This Post Posted: 10 August 2006 at 3:43am
Originally posted by zeli zeli wrote:


Now my question is, how do I put that into my homepage?

 
Umm?
If you look at the first few lines of code you have:
 
<%
' to be used as an include on another page, like
' <!--#include virtual = "/forum/last_ten_posts.asp" -->
%>
So... where you want the last xx posts to appear you use:
 
<!--#include virtual = "/forum/last_ten_posts.asp" -->
 
Assuming of course that your home page is an .asp page
 
.
Back to Top
zeli View Drop Down
Newbie
Newbie


Joined: 06 August 2006
Location: United States
Status: Offline
Points: 10
Post Options Post Options   Thanks (0) Thanks(0)   Quote zeli Quote  Post ReplyReply Direct Link To This Post Posted: 10 August 2006 at 3:46am
ah! that didnt work so i dont think it is. :P

thank you though! I'll check with a friend and see how i convert it so i can use this.

Back to Top
 Post Reply Post Reply Page  <1234 5>

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.