Log in

View Full Version : Howto: have the 10 newest posts on my homepage


jer2eydevil88
08-14-2007, 04:02 PM
I would like to have the 10 newest posts titles show up on the homepage for my site, the best idea I can come up with is to use an rss feed reader (although I don't think the forum software supports feeds) or something equivalent to that unless someone has a better idea.

nico_swd
08-14-2007, 09:36 PM
(although I don't think the forum software supports feeds)

https://vborg.vbsupport.ru/faq.php?faq=vb_board_usage#faq_vb_rss_syndication

EnIgMa1234
08-14-2007, 10:13 PM
Create a new plugin

Product: vBulletin
Hook: forumhome_complete

In the box add:
$query = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "thread ORDER BY lastpost DESC LIMIT 10");

while ($last = $vbulletin->db->fetch_array($query))
{
$lasttitle = $last['title']<br />;
}


Now you can use $lasttitle in your forumhome template

amnesia623
09-03-2007, 10:36 PM
This only displays one 'latest thread'

Is there a way to fix it?
Thanks!

Opserty
09-04-2007, 10:09 AM
He forgot a '.' :p

$query = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "thread ORDER BY lastpost DESC LIMIT 10");

while ($last = $vbulletin->db->fetch_array($query))
{
// If you want to link to the thread to use $lasttitle .= '<a href="showthread.php?t='. $last['threadid'] .'">'. $last['title'] .'</a><br />';
$lasttitle .= $last['title']<br />;
}

amnesia623
09-04-2007, 03:20 PM
AHH...thank you!

How would you go about coding this to follow forum permissions?

I really appreciate any help!

amnesia623
02-02-2008, 04:44 PM
Does this still work in 3.7? I can't seem to get it to work...

mrkhm
04-12-2008, 10:30 PM
thank you this works perfectly in vb 3.6.x

quick question for anyone is there anyway to limit it to only show titles from specific forums should i be doing

select * from where something something is = to something

thanks anyway

Opserty
04-13-2008, 08:50 AM
thank you this works perfectly in vb 3.6.x

quick question for anyone is there anyway to limit it to only show titles from specific forums should i be doing

select * from where something something is = to something

thanks anyway

Change the MySQL query to:

SELECT title, threadid FROM ". TABLE_PREFIX ."thread WHERE forumid IN (X, Y, Z) ORDER BY lastpost DESC LIMIT 10"

Change title, threadid to * if you want to select all fields.

X, Y, Z Being a comma separated list of the ForumID numbers.

mrkhm
06-27-2008, 08:45 AM
ahhh! many thanks opserty! that works absolutely absolutely perfectly

callumbush
06-29-2008, 04:15 PM
Hi all,

I've created the plugin, but I don't understand the part about putting $lasttitle in my forumhome template.

I tried deleting everything in <!-- main --> in forumhome, and replacing it with '$lasttitle', but it looks like that wasn't correct :P

Please help :)

Callum

p.s. In case its relevant, I'm currently using vBulletin 3.7.0

Opserty
06-29-2008, 04:30 PM
Just type $lasttitle into your FORUMHOME template.

BANDiT600
06-29-2008, 04:37 PM
And how to put this on non-vBulletin page??? I want to use last 10 posts in forum on a main page of my site.

callumbush
06-29-2008, 04:48 PM
Just type $lasttitle into your FORUMHOME template.

It doesn't appear to do anything to my homepage.

Where should I include it? Here's my FORUMHOME

$stylevar[htmldoctype]
<html xmlns="http://www.w3.org/1999/xhtml" dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Cache-Control" content="no-cache" />
<!-- end no cache headers -->
$headinclude
<title>$vboptions[bbtitle]
</title>
</head>
<body>
$header
$navbar

<if condition="$show['guest']">
<!-- guest welcome message -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat"><img src="$stylevar[imgdir_misc]/tcat_tl.gif" alt="" border="0" style="position:relative; top: -7px; left: -7px; float:left;" />
<img src="$stylevar[imgdir_misc]/tcat_tr.gif" alt="" border="0" style="position:relative; top: -7px; left: 7px; float:right;" />
<phrase 1="$vboptions[bbtitle]">$vbphrase[welcome_to_the_x]</phrase></td>
</tr>
<tr>
<td class="alt1">
<phrase 1="faq.php$session[sessionurl_q]" 2="register.php$session[sessionurl_q]">$vbphrase[first_visit_message]</phrase>
</td>
</tr>
</table>
<div class="bcorner"><div class="bcrn-c"><div class="bcrn-l"></div><div class="bcrn-r"></div></div></div>
<!-- / guest welcome message -->
<br />
</if>

<!-- main -->

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
$forumbits
<tbody>
<tr>
<td class="tfoot" align="center" colspan="<if condition="$vboptions['showmoderatorcolumn']">6<else />5</if>"><div class="smallfont"><strong>
<a href="forumdisplay.php?$session[sessionurl]do=markread" rel="nofollow">$vbphrase[mark_forums_read]</a>
<if condition="$vboptions['forumleaders']">&nbsp; &nbsp;
<a href="showgroups.php$session[sessionurl_q]">$vbphrase[view_forum_leaders]</a></if>
</strong></div></td>
</tr>
</tbody>
</table>
<div class="bcorner"><div class="bcrn-c"><div class="bcrn-l"></div><div class="bcrn-r"></div></div></div>
$forumhome_markread_script
<!-- /main -->

<br />
$ad_location[ad_forumhome_afterforums]
<br />

<!-- what's going on box -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="2"><img src="$stylevar[imgdir_misc]/tcat_tl.gif" alt="" border="0" style="position:relative; top: -7px; left: -7px; float:left;" />
<img src="$stylevar[imgdir_misc]/tcat_tr.gif" alt="" border="0" style="position:relative; top: -7px; left: 7px; float:right;" />
$vbphrase[whats_going_on]</td>
</tr>
</thead>
<if condition="$show['loggedinusers']">
<!-- logged-in users -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_activeusers')"><img id="collapseimg_forumhome_activeusers" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_activeusers].gif" alt="" border="0" /></a>
<a href="online.php$session[sessionurl_q]">$vbphrase[currently_active_users]</a>: $totalonline (<phrase 1="$numberregistered" 2="$numberguest">$vbphrase[x_members_and_y_guests]</phrase>)
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_activeusers" style="$vbcollapse[collapseobj_forumhome_activeusers]">
<tr>
<td class="alt2"><a href="online.php$session[sessionurl_q]"><img src="$stylevar[imgdir_misc]/whos_online.gif" alt="$vbphrase[view_whos_online]" border="0" style="padding: 10px;" /></a></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div style="white-space: nowrap"><phrase 1="$recordusers" 2="$recorddate" 3="$recordtime">$vbphrase[most_users_ever_online_was_x_y_at_z]</phrase></div>
<div>$activeusers</div>
</div>
</td>
</tr>
</tbody>
<!-- end logged-in users -->
</if>
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_stats')"><img id="collapseimg_forumhome_stats" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_stats].gif" alt="" border="0" /></a>
<phrase 1="$vboptions[bbtitle]">$vbphrase[x_statistics]</phrase>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_stats" style="$vbcollapse[collapseobj_forumhome_stats]">
<tr>
<td class="alt2"><img src="$stylevar[imgdir_misc]/stats.gif" alt="<phrase 1="$vboptions[bbtitle]">$vbphrase[x_statistics]</phrase>" border="0" style="padding: 10px;" /></td>
<td class="alt1" width="100%">
<div class="smallfont">
<div>
$vbphrase[threads]: $totalthreads,
$vbphrase[posts]: $totalposts,
$vbphrase[members]: $numbermembers<if condition="$show['activemembers']">,
<span title="<phrase 1="$vboptions[activememberdays]">$vbphrase[within_the_last_x_days]</phrase>">$vbphrase[active_members]: $activemembers</span>
</if>
</div>
<div><phrase 1="member.php?$session[sessionurl]u=$newuserid" 2="$newusername">$vbphrase[welcome_to_our_newest_member_x]</phrase></div>
</div>
</td>
</tr>
</tbody>
<if condition="$show['birthdays']">
<!-- today's birthdays -->
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_birthdays')"><img id="collapseimg_forumhome_birthdays" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_birthdays].gif" alt="" border="0" /></a>
$vbphrase[todays_birthdays]
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_birthdays" style="$vbcollapse[collapseobj_forumhome_birthdays]">
<tr>
<td class="alt2"><a href="calendar.php?$session[sessionurl]do=getday&amp;day=$today&amp;sb=1"><img src="$stylevar[imgdir_misc]/birthday.gif" alt="$vbphrase[view_birthdays]" border="0" style="padding: 10px;" /></a></td>
<td class="alt1" width="100%"><div class="smallfont">$birthdays</div></td>
</tr>
</tbody>
<!-- end today's birthdays -->
</if>
<if condition="$show['upcomingevents']">
<tbody>
<tr>
<td class="thead" colspan="2">
<a style="float:$stylevar[right]" href="#top" onclick="return toggle_collapse('forumhome_events')"><img id="collapseimg_forumhome_events" src="$stylevar[imgdir_button]/collapse_thead$vbcollapse[collapseimg_forumhome_events].gif" alt="" border="0" /></a>
<if condition="$show['todaysevents']">$vbphrase[todays_events]<else /><phrase 1="$vboptions[showevents]">$vbphrase[upcoming_events_for_the_next_x_days]</phrase></if>
</td>
</tr>
</tbody>
<tbody id="collapseobj_forumhome_events" style="$vbcollapse[collapseobj_forumhome_events]">
<tr>
<td class="alt2"><a href="calendar.php$session[sessionurl_q]"><img src="$stylevar[imgdir_misc]/calendar.gif" alt="$vbphrase[calendar]" border="0" style="padding: 10px;" /></a></td>
<td class="alt1" width="100%"><div class="smallfont">$upcomingevents</div></td>
</tr>
</tbody>
</if>
</table>
<div class="bcorner"><div class="bcrn-c"><div class="bcrn-l"></div><div class="bcrn-r"></div></div></div>
<br />
<!-- end what's going on box -->

<!-- icons and login code -->
<table cellpadding="0" cellspacing="2" border="0" width="100%">
<tr valign="bottom">
<td>
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td><img src="$stylevar[imgdir_statusicon]/forum_new.gif" alt="$vbphrase[contains_new_posts]" border="0" /></td>
<td class="smallfont">&nbsp; $vbphrase[forum_contains_new_posts]</td>
</tr>
<tr>
<td><img src="$stylevar[imgdir_statusicon]/forum_old.gif" alt="$vbphrase[contains_no_new_posts]" border="0" /></td>
<td class="smallfont">&nbsp; $vbphrase[forum_contains_no_new_posts]</td>
</tr>
<if condition="$vboptions['showlocks']">
<tr>
<td><img src="$stylevar[imgdir_statusicon]/forum_old_lock.gif" alt="$vbphrase[a_closed_forum]" border="0" /></td>
<td class="smallfont">&nbsp; $vbphrase[forum_is_closed_for_posting]</td>
</tr>
</if>
</table>
</td>
<if condition="!$show['guest']">
<!-- member logout -->
<td align="$stylevar[right]"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out('$vbphrase[sure_you_want_to_log_out]')"><phrase 1="$bbuserinfo[username]">$vbphrase[log_out_x]</phrase></a></td>
<!-- end member logout -->
</if>
</tr>
</table>
<!-- / icons and login code -->

$footer
</body>
</html>


And here's the plugin I created (I've checked its active!):

$query = $vbulletin->db->query_read("SELECT * FROM " . TABLE_PREFIX . "thread ORDER BY lastpost DESC LIMIT 10");

while ($last = $vbulletin->db->fetch_array($query))
{
// If you want to link to the thread to use $lasttitle .= '<a href="showthread.php?t='. $last['threadid'] .'">'. $last['title'] .'</a><br />';
$lasttitle .= $last['title']<br />;
}

mrkhm
06-29-2008, 06:01 PM
hi, i remember this happening to me, it may be something simple, (just check it out) --> it could be that where you have installed the actual plug in is incorrect i.e. go into plugin manager, find $lasttitle edit it and ensure that "hook location" is "forum home complete" and that it is number "5" in order of execution.

i have literally 5 instances of lasttitle on my board, i.e. lasttitle1, lasttitle 2, for different forum categories etc and each time when the threads dont show up, it is ALWAYS the hook location that needed fiddling with, just check the hook location and then paste $lasttitle wherever in the page you want it to appear.

callumbush
06-29-2008, 06:33 PM
hi, i remember this happening to me, it may be something simple, (just check it out) --> it could be that where you have installed the actual plug in is incorrect i.e. go into plugin manager, find $lasttitle edit it and ensure that "hook location" is "forum home complete" and that it is number "5" in order of execution.

i have literally 5 instances of lasttitle on my board, i.e. lasttitle1, lasttitle 2, for different forum categories etc and each time when the threads dont show up, it is ALWAYS the hook location that needed fiddling with, just check the hook location and then paste $lasttitle wherever in the page you want it to appear.

hey, cheers for the help :)

Okay those settings were correct, but I hadn't named the plugin title as "$lasttitle". I have now renamed it but it still doesnt work :S

Opserty
06-29-2008, 07:54 PM
I don't see the $lasttitle variable in your FORUMHOME template... The plugin name is irrelevant the only things you need to worry about is the PHP code and the hook location. Both of which have been shown to work...

Are you sure you are editing the correct skin? (the same as which you are viewing)

Else try this: http://www.vbulletin.com/forum/showthread.php?t=158887