Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Display Last X Posts on front page Details »»
Display Last X Posts on front page
Version: 1.20, by RonHiler RonHiler is offline
Developer Last Online: Aug 2013 Show Printable Version Email this Page

Version: 2.3.x Rating:
Released: 04-01-2005 Last Update: Never Installs: 3
 
No support by the author.

Hey all,

This MUST have been done, I see it was requested something like a million times by various people, and it's probably the single most common hack ever done, heh. But surprisingly, I could not for the life of me find a mod that did what I wanted.

What I wanted is very simple. Display the last 10 postings on my front page. Not by thread. Not the last 10 posts of the last 10 threads, but the LAST 10 POSTS, even when they happen to be in the same thread.

I achieved this by modifying a mod that already existed (I actually installed it thinking it did what I wanted, but in fact it only displayed the last 10 posts that were in different threads). It's not my intent to take full credit for this mod, the groundwork was already laid by someone else (I'd provide a link to the original, but I can't seem to find it now, grrr, perhaps somebody knows it and can provide the link).

So, here is my version. It provides the time, thread name, and poster name, with links to the post and to the user profile. You can see an example of it working on my front page (www.rjcyberware.com). The only thing I don't like is that it uses server time in the display. I'd like to change that to the user local time, but I'll have to look over the php time commands to see if it's possible to do.

Here is the code
Code:
<?php
/* This script shows the last X numbers of posts (titles) posted last on a non-VB page. You may customize it in any way you wish. */

## CUSTOMIZE SETTINGS FOR YOUR SITE ##
$db_host = "localhost"; // Change this if your MySQL database host is different.
$db_name = "DATABASE"; // Change this to the name of your database.
$db_user = "USER"; // Change this to your database username.
$db_pw = "PASSWORD"; // Change this to your database password.
$db_prefix="PREFIX";  //Change this to your database prefix, if any.  Leave blank if you don't use a prefix.

$forum_url = "http://www.YOURSITE.com/forums"; // Change this to reflect to your forum's URL.
$limit = "10"; // Number of posts displayed.
$titlecolor = "#000000"; // This is the color of the title (first line)
$linkcolor = "#404040"; // This is the color of the linked text (second and third line)
$backgroundcolor = "#ffffff"; // Set this if you want a different background color than the default, otherwise leave empty
$txtlimit = "100"; // This is the character limit.
#######################################

// Connecting to your database
mysql_connect($db_host, $db_user, $db_pw)
OR die ("Cannot connect to your database");
mysql_select_db($db_name) OR die("Cannot connect to your database");

$table_post = $db_prefix."post";
$table_thread = $db_prefix."thread";
$result = mysql_query("SELECT postid FROM $table_post WHERE visible=1");
$num_rows = mysql_num_rows($result);
echo "<CENTER><U><B>Latest Forum Activity</U><BR>";
echo "Total Posts: $num_rows</CENTER></B><BR><BR>";

// Below is the beginning of a table. If you feel you don't need it, you may remove it. ?>
<table border="1" cellspacing="0" bordercolordark="white" bordercolorlight="black" width="100%">

<?php
if ($limit) {
	$limited = "LIMIT $limit";
}
$post_sql = mysql_query("SELECT postid,threadid,username,userid,dateline FROM $table_post WHERE visible=1 ORDER BY postid DESC $limited");

while($post_get=mysql_fetch_array($post_sql))
{
$dateline= $post_get['dateline'];
$date2 = date ("d M Y h:i a" ,$dateline);
$tid = $post_get['threadid'];
$thread_sql = mysql_query("SELECT title FROM $table_thread WHERE threadid=$tid");
$thread_get = mysql_fetch_array($thread_sql);
$title = $thread_get['title'];
$title = substr($title,0,$txtlimit);
$pid=$post_get['postid'];
$poster = $post_get['username'];
$userid = $post_get['userid'];
//the output line
echo "<tr'><td BGCOLOR=\"$backgroundcolor\">
<font size='2' COLOR=\"$titlecolor\">$date2<BR></font>
<a href=\"$forum_url/showthread.php?p=$pid#post$pid\"><font size='2' LINK=\"$linkcolor\" VLINK=\"$linkcolor\">$title</font></a><BR>
<a href=\"$forum_url/member.php?userid=$userid\"><font size='2' LINK=\"$linkcolor\" VLINK=\"$linkcolor\"><i>$poster</i></font></a>
</td></tr>";
}
echo "</table>";

?>
To use it, save it as a file (as say "DisplayPosts.php", and where you want to display the posts, just add in the line:
<?php include ("/YOURPATH/DisplayPosts.php"); ?>

If anyone has any suggestions for improvements, feel free.

Ron

[EDIT v1.1: Changed code to make the database prefix a modifiable field which gets propigated into the database queries]
[EDIT v1.2: Changed code such that the modifiable fields "$titlecolor" and "$linkcolor" actually do something useful, and added in "$backgroundcolor" to change the table entry backgrounds. Broke up the output line to make it a little easier to read]

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #22  
Old 04-03-2005, 07:20 PM
RonHiler RonHiler is offline
 
Join Date: Mar 2005
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Jugo, thanks for the links! That Mod was my starting point that I changed to make mine. I was hoping someone would post it I don't know WHY I couldn't find it again. RobinHood deserves a good deal of the credit for my contribution.

It doesn't dispaly the last X posts, which is why I had to modify it. It displays the last 10 posts that are in different threads, which is not what I wanted. It's a subtle difference, but an important one for me

Selene: I wish I could help, but I know next to nothing about postnuke. Probably your best bet is to post the code for the mod in the postnuke forum (just make sure to remove your real database name, database user, password, and path information first). They would probably have a better idea of what is going wrong than the people here.

New version 1.2: Based on Selene's request, added values for the text color, links colors, and background color to the modifiables section. All you need to do is set these values, and the output should appear in the desired colors.

[BTW: Can a moderator/admin move this thread into the vB3 section? I have no idea how it ended up in vB2 mods, I must have screwed up - Thanks]

Ron
Reply With Quote
  #23  
Old 04-04-2005, 06:44 PM
jugo jugo is offline
 
Join Date: Feb 2004
Location: Reading your emails.
Posts: 573
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Selene
hendri i still cant get it to work with postnuke as block. can u see the url in my previous post and check the error. wud be nice if I can get it to work in postnuke

SELENE

You have to remove the:

Quote:
<?php
and
Quote:
?>
Lines from the code since postnuke will insert the code into it's existing functions.
Reply With Quote
  #24  
Old 04-25-2006, 07:50 PM
jwashburn jwashburn is offline
 
Join Date: Apr 2006
Posts: 66
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What would I change to make it show it shows only the first post of each of the last x number of threads.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:47 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03762 seconds
  • Memory Usage 2,240KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (3)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete