• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

latest posts

#1
Im making a invision forum and i wanna know how i can get a list of the latest 5 post on my site.

im a complete php newbie, so please be very clear. Hope you guys can help me.
 

Electronic Punk

willalwaysbewithyou
Staff member
Political User
#2
Make a new file or function with the foillowing content:

Code:
$recentforumget = 5; // Number of posts to get
$recentforumlength = 30; // Length of title to display before cutting off
$forumexclude = ""; // Add forum id's to exclude from get (eg private ones) sepetate by a comma

$getposts = query("SELECT tid,title,forum_id FROM ".$ibf_prefix."topics WHERE  (state <> 'link')".iif($forumexclude," AND (forum_id NOT IN ($forumexclude))")." ORDER BY last_post DESC LIMIT $recentforumget");

while ($post = fetch_array($getposts)) {
$post[short_title] = iif(strlen($post[title]) > $recentforumlength,substr($post[title],0,$recentforumlength)."...",$post[title]);
$post[full_title] = $post[title];
$recentforumposts .= "<a href=\"$forumpath/index.php?act=ST&f=$post[forum_id]&t=$post[tid]\" title=\"$post[full_title]\">$post[short_title]</a><br />\n";
}
 
#3
hmmm.... :confused: :( You have to help me a bit more. Where do i have to put this code. Im a extremely newbie i need everything i steps :p Thanks for helping me
 
#4
Put the code anywhere (pretty much) inside <? ?> -tags.
Then at the place you want to print the links type in:
<?=$recentforumposts?>
 
#5
this is what i have now and it still not work, what am i doing wrong:

<?
$recentforumget = 5; // Number of posts to get
$recentforumlength = 30; // Length of title to display before cutting off
$forumexclude = ""; // Add forum id's to exclude from get (eg private ones) sepetate by a comma

$getposts = query("SELECT tid,title,forum_id FROM ".$ibf_prefix."topics WHERE (state <> 'link')".iif($forumexclude," AND (forum_id NOT IN ($forumexclude))")." ORDER BY last_post DESC LIMIT $recentforumget");

while ($post = fetch_array($getposts)) {
$post[short_title] = iif(strlen($post[title]) > $recentforumlength,substr($pos
t[title],0,$recentforumlength)
."...",$post[title]);
$post[full_title] = $post[title];
$recentforumposts .= "<a href=\"$forumpath/index.php?act=ST&f=$post[forum_id]&t=$post[tid]\" title=\"$post[full_title]\">$post[short_title]</a><br />\n";
}
?>

<?=$recentforumposts?>
 
#7
hmmm i get a bunch of weird text, but no error. But nevermind i installed the Invision Portal and that does exactly what i want. Thanks for helping me.
 

Members online

No members online now.

Latest posts

Latest profile posts

Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,961
Messages
673,239
Members
89,013
Latest member
Pdawgintown