View Full Version : 2nd Latesttopics module / from specific forum(s)
tomshawk
12-18-2004, 02:04 AM
Hello Everyone,
Over the last few months I have seen this asked for many times.
Brian has given instructions on how to do this, but, I thought it'd be easier to type this up, and post it here for people to find a little easier.
All Credit for this goes to Brian ;)
What this does, It creates a new module for the CMPS homepage, that pulls posts just like the latest Topics module, but for a specific forum or 2, plus the amount of posts in this block is customized to a different amount other then what is in the vBa Default settings.
I hope this helps everyone, good luck and enjoy ;)
Update
Thanks to SVTOA for pointing out a few mistakes
I have updated the Instructions to correct them, and add a few more instructions ;)
Brian
12-18-2004, 10:49 AM
Thanks for sharing. I'm sure many people will find it useful. :)
SVTOA
12-18-2004, 12:54 PM
Excellent! This makes it so we can add a module called "Latest Classifed ads" :D
SVTOA
12-18-2004, 01:33 PM
Ok, I followed the instructions to the letter, and it works properly except for one problem- The module title still says "Latest Forum Topics". The correct threads are pulled from the forum, but I cannot get the conditional statement in adv_portal_latesttopics" to work properly. I have checked and double-checked for errors, there are none. Any ideas?
SVTOA
12-18-2004, 01:48 PM
Ok, I fixed it myself. I think you have an error in the instructions-
When I used this instruction, it didn't change the module title:
Look for $vbphrase[latest_forum_topics]
If you are only going to create one new block, for Articles, replace the above with this
<if condition="$mod['identifier'] == 'Latest_Articles' ">Latest_Articles<else />$vbphrase[latest_forum_topics]</if>
However when I did it this way, it works perfectly:
<if condition="$mods['identifier'] == 'Latest_Articles'">Latest Articles</if>
<if condition="!$mods['identifier']">$vbphrase[latest_forum_topics]</if>
Note also that in your instructions you have a _ included in the module Name, you do not have to have that unless you want your module title to display as "Latest_Articles" versus "Latest Articles"
Anyway, great job and this is VERY useful, thank you very much!
SVTOA
12-18-2004, 01:56 PM
I have one more suggestion, if I may? For more functionality, you could also make the new Block's title into a hyperlink to that Forum, so that someone can click the title of the new block and be transfered to that forum, if the block has posts from a single forum.
SVTOA
12-18-2004, 02:21 PM
Man I hope I'm not driving you guys crazy with my suggestions, but.. We should be able to code an option into the original "latesttopics.php" to exclude any forum ID that is inputted into the new module, so you do not have "double topics" in these modules? What I mean is, for example I have taken this mod and made a "Latest Classifieds" module which of course only displays the most recent classifed ads placed in our classifeds forum. But the "problem" is that these same threads may also display in the "Latest Topics" block too. It would be nice to be able to exclude them from displaying in the latest topics block and only have them display in the "Latest Classifeds" block. if you exclude them in the CMPS control panel, you exclude them from your new block as well. is there a workaround to this?
SVTOA
12-18-2004, 02:33 PM
Well, as I talk to myself here, I have got this to work perfectly. Since my classifeds forums are open for viewing by anyone, I have no need for any usergroup permissions relative to those forums. So here is what I did- In my latestclassifeds.php file (custom made per this hack) I simply removed the whole forum permissions codeblock from that file, then I excluded the classifeds forums from the CMPS control panel for the "Latest Topics" block. The result is that no classifed ad posts appear in the latest topics module, and the new classifed ads appear as they should in the "latest classifieds" module.
I'm a happy camper and thanks again for a great portal and great add-ons and hacks. :D
SVTOA
12-18-2004, 02:36 PM
FYI, if anyone else wants to do this, this is the code I removed from latestclassifeds.php (or whatever you decide to call your new module's php page)
$inforums = '';
if ($vba_options['portal_threads_forumids'])
{
if (!empty($forumperms))
{
$inforums = array();
$threadsforums = explode(',', $vba_options['portal_threads_forumids']);
foreach ($threadsforums AS $tforum)
{
if (!in_array($tforum, $forumperms))
{
$inforums[] = $tforum;
}
}
if (!empty($inforums))
{
$inforums = implode(',', $inforums);
}
}
else
{
$inforums = $vba_options['portal_threads_forumids'];
}
if ($inforums)
{
$inforums = 'AND thread.forumid IN (' . $inforums . ')';
}
}
tomshawk
12-18-2004, 03:32 PM
WOW SVTOA,
I'm glad you like the hack and have found ways to make it better ;)
I will take a look at the problem in the instructions and update them ;)
What I do on my boards so posts dont show up in both is add the articles boards to the excludes of the latest topics ;) I should have mentioned this in the instructions :p
Nice idea about removing the usergroup section.
I set up my articles so you need to post a few times, then your account automatically upgrades to a group that can see the articles, so that section, I could remove as well, because with my "articles block", you can not even see it as an unregistered user or a registered user, because your account has not upgraded yet. ;)
Did that make sense? :p
Anyway, Thank you for your interest ;)
SVTOA
12-18-2004, 03:43 PM
You're most welcome sir. I guess I took the long way home but got there just the same! :D
This is one of the better modules, thank you again, much appreciated.
tomshawk
12-18-2004, 04:04 PM
Update:!!
Thanks to SVTOA for pointing out a few mistakes
I have updated the Instructions to correct them, and add a few more instructions
theMusicMan
12-18-2004, 06:22 PM
Hey Tomshawk, this is a great little module enhancement and I'd like to say thanks for including it here. I haven't installe dit yet but I most certainly will do so when I need to in the new year.
Thanks for this...
1996 328ti
12-26-2004, 08:04 PM
Linking the block name is easy enough with basic html ;)
But the problem I have is that the tables are not the same. :(
Compare lastest classifieds with latest topics.
www.318ti.org
Does it have something to do where the switch is?
tomshawk
12-26-2004, 08:20 PM
very interesting.
Nothing in the code I posted, should have done that.
If you move them to the side, (for testing purposes) do they look correct, or do they look strange?
1996 328ti
12-26-2004, 08:35 PM
If you move them to the side, (for testing purposes) do they look correct, or do they look strange?
They look identical in either the left or right column.
Weird? :confused:
I didn't see any reason why it should be different.
I think the problem is so obvious that we can't see it.
I guess most people use the side columns for these blocks.
BTW- This is really cool that you posted it. Thanks!
1996 328ti
12-26-2004, 10:47 PM
The problem is the forum table.
Last Topics has a forum name Announcements. That is making the column wide enough to fit. But no matter what I do to
<td align="center" class="thead" width="20%"><span class="smallfont">$vbphrase[forum]</span></td>
I can't get the cell big enough to make it work for both.
tomshawk
12-27-2004, 03:40 AM
Ahh, The forum name, I can see where that would be a problem, when you have a long forum name.
I'm sorry I dont have a solution, other then renaming your boards, which Obviously is not a good answer. :(
shiva
12-27-2004, 04:00 AM
Nice module. one of the first I added. (yes, I finally got up and running, great cms btw)
If there was a "install" button here, i would be clicking it. :)
1996 328ti
12-27-2004, 07:58 AM
Ahh, The forum name, I can see where that would be a problem, when you have a long forum name.
I'm sorry I dont have a solution, other then renaming your boards, which Obviously is not a good answer. :(
I think it is a simply html issue. I'll work on it when I have some extra time.
Thanks for a cool hack though.
The other thing I can do is put it on the side.
lee wilde
01-14-2005, 11:56 AM
THANK YOU!! How many hours have I spent fiddling around trying to accomplish the same result. This hack is going to enable me to do a few things I really wanted to, but was unable to until now. Very cool.
lasto
01-15-2005, 10:16 AM
The problem is the forum table.
Last Topics has a forum name Announcements. That is making the column wide enough to fit. But no matter what I do to
<td align="center" class="thead" width="20%"><span class="smallfont">$vbphrase[forum]</span></td>
I can't get the cell big enough to make it work for both.
can we not knock the forum name off the actual template as im having this problem - its making 1 line turn into 2 lines and does`nt look good to be honest.
Anyone know how to do it and what template to remove the last column which displays what forum it is in.
lee wilde
01-16-2005, 12:17 AM
can we not knock the forum name off the actual template as im having this problem - its making 1 line turn into 2 lines and does`nt look good to be honest.
Anyone know how to do it and what template to remove the last column which displays what forum it is in.
adv_portal_latesttopics - remove the "forum" column heading
adv_portal_latesttopicbits - remove the forum information
In each template, remove the entire column by deleting the <td> down to the </td>
lee wilde
01-16-2005, 12:22 AM
Tomshawk (or anyone else who knows)....is it possible to have a similar hack to create a 2nd News module?
adv_portal_newsbits
forums/modules/news.php
tomshawk
01-16-2005, 03:14 AM
Tomshawk (or anyone else who knows)....is it possible to have a similar hack to create a 2nd News module?
adv_portal_newsbits
forums/modules/news.php
I'll play with this on my test boards, but..
I cant promise to much, Brian is the originator of this hack, but again, I'll try ;)
lasto
01-16-2005, 08:24 AM
adv_portal_latesttopics - remove the "forum" column heading
adv_portal_latesttopicbits - remove the forum information
In each template, remove the entire column by deleting the <td> down to the </td>
totally messed it up can someone supply the two templates for me
also one template does not have <td> in it at all
tomshawk
01-16-2005, 11:29 AM
totally messed it up can someone supply the two templates for me
also one template does not have <td> in it at all
You can revert it, and it will go back to original, then just reapply the hack from my instructions, and any other hacks you have installed.
That will get you back to normal ;)
lasto
01-16-2005, 11:26 PM
yeah i put em back but i cant suzz out what code to remove so last column does`nt show as your instructiosn say remove all code from the <td> downwards but u need to check cause one template does`nt even have the <td> code in and its that template that is showing the last column
tomshawk
01-17-2005, 12:51 AM
yeah i put em back but i cant suzz out what code to remove so last column does`nt show as your instructiosn say remove all code from the <td> downwards but u need to check cause one template does`nt even have the <td> code in and its that template that is showing the last column
Actually that was lee wilde thats said to do that, my instructions dont say anything about the <td> downwards
I did look in the 2 templates lee pointed you to, and I dont see it either
and I wouldn't know how to do it. sorry
lasto
01-17-2005, 05:20 AM
cheers m8 - anyone readin this can u post the 2 templates but with the last column missing plz :)
lee wilde
01-20-2005, 11:27 PM
cheers m8 - anyone readin this can u post the 2 templates but with the last column missing plz :)
Cheers :)
adv_portal_latesttopics
<!-- Latest Threads -->
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder"width="100%">
<tr>
<td <if condition="$mods['modcol'] == 1">colspan="6"</if> class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] $vbphrase[latest_forum_topics]</strong></span></td>
</tr>
<if condition="$mods['modcol'] == 1">
<tr>
<if condition="$vba_options['portal_threads_showicon']">
<td class="thead" width="5"> </td>
</if>
<td class="thead" width="100%"><span class="smallfont">$vbphrase[title_username_date]</span></td>
<if condition="$show['lastpost']">
<td align="center" class="thead" nowrap="nowrap" width="25%"><span class="smallfont">$vbphrase[last_post]</span></td>
</if>
<td class="thead" width="15"><span class="smallfont">$vbphrase[replies]</span></td>
<td class="thead" width="15"><span class="smallfont">$vbphrase[views]</span></td>
</tr>
</if>
$threadbits
</table>
<br />
<!-- End Latest Threads -->
adv_portal_latesttopicbits
<if condition="$mods['modcol'] == 1">
<tr>
<if condition="$vba_options['portal_threads_showicon']">
<td class="alt2"><if condition="$show['threadicon']"><img alt="" border="0" src="$thread[threadiconpath]" title="$thread[threadicontitle]" /></if></td>
</if>
<td class="alt1">
<if condition="$thread['subscribed']">
<span style="float:$stylevar[right]"><img alt="" class="inlineimg" src="$stylevar[imgdir_misc]/subscribed.gif" title="$vbphrase[you_are_subscribed_to_this_thread]" /></span>
</if>
<b><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="$thread[preview]">$thread[title]</a></b>
<if condition="$thread['rating']">
<span style="float:$stylevar[right]"><img alt="" src="$stylevar[imgdir_rating]/rating_$thread[rating].gif" title="<phrase 1="$thread[votenum]" 2="$thread[voteavg]">$vbphrase[thread_rating_x_votes_y_average]</phrase>" /></span>
</if>
<div class="smallfont"><span style="cursor:pointer" onclick="window.open('$vboptions[bburl]/member.php?$session[sessionurl]u=$thread[postuserid]')">$thread[postusername]</span>
</div>
</td>
<if condition="$show['lastpost']">
<td class="alt2">
<div class="smallfont" style="text-align:right; white-space:nowrap">$thread[lastpostdate] <span class="time">$thread[lastposttime]</span><br /><phrase 1="$vboptions[bburl]/member.php?$session[sessionurl]find=lastposter&t=$thread[threadid]" 2="$thread[lastposter]">$vbphrase[by_x]</phrase> <a href="$vboptions[bburl]/showthread.php?$session[sessionurl]goto=lastpost&t=$thread[threadid]"><img alt="" border="0" src="$stylevar[imgdir_button]/lastpost.gif" title="$vbphrase[go_to_last_post]" /></a></div>
</td>
</if>
<td align="center" class="<if condition="$show['lastpost']">alt1<else />alt2</if>"><span class="smallfont">$thread[replycount]</span></td>
<td align="center" class="<if condition="$show['lastpost']">alt2<else />alt1</if>"><span class="smallfont">$thread[views]</span></td>
</tr>
<else />
<tr>
<td class="$getbgrow">
<if condition="$show['threadicon']">
<img alt="" src="$thread[threadiconpath]" border="0" title="$thread[threadicontitle]" />
</if>
<if condition="$thread['subscribed']">
<img alt="" class="inlineimg" src="$stylevar[imgdir_misc]/subscribed.gif" title="$vbphrase[you_are_subscribed_to_this_thread]" />
</if>
<span class="smallfont"><strong><a href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" title="<if condition="$thread[preview]">$thread[preview]
</if>$vbphrase[by] $thread[postusername] <if condition="$vba_options['portal_threads_showdate']">$thread[postdate] $thread[posttime]</if>">$thread[title]</a></strong></span>
<if condition="$thread['rating']">
<div style="margin-top:4px"><img alt="" src="$stylevar[imgdir_rating]/rating_$thread[rating].gif" title="<phrase 1="$thread[votenum]" 2="$thread[voteavg]">$vbphrase[thread_rating_x_votes_y_average]</phrase>" /></div>
</if>
<if condition="$show['lastpost']">
<div class="smallfont" style="margin-top:4px"><a href="$vboptions[bburl]/showthread.php?$session[sessionurl]goto=lastpost&t=$thread[threadid]"><img alt="" border="0" src="$stylevar[imgdir_button]/lastpost.gif" title="$vbphrase[go_to_last_post]" /></a> $vbphrase[last_post_by] <a href="$vboptions[bburl]/member.php?find=lastposter&t=$thread[threadid]">$thread[lastposter]</a></div>
</if>
<div class="smallfont">$thread[lastpostdate] <span class="time">$thread[lastposttime]</span></div>
<div class="smallfont">$thread[replycount] $vbphrase[replies], $thread[views] $vbphrase[views]</div></td>
</tr>
</if>
lasto
01-22-2005, 03:44 AM
works perfect cheers m8
TomsHawk
Fantastic worked the first time I installed it,
Lets say I wanted to add some teaser( I guess tahst what the call it) text to it how would I go about doing that, anyone have anyidea?
I guess this would make it kinda like the news module
Delw
tomshawk
02-02-2005, 02:19 AM
Delw,
when you say teaser, can you elaborate?
What do you want to see?
Nordinho
03-21-2005, 01:39 PM
Hey Tomshawk,
Thanks for this. Works great, but I would like to only show the latest threads by the date they were created (instead of the latest replies). So f.e. I have a games forum and I would like to pull the latest games from a forum, and not the latest replies...Any idea's??
tomshawk
03-22-2005, 09:46 AM
I have not tryed it yet, so I am not positive but, try this
Open your new latesttopics file
Find this
ORDER BY lastpost DESC
and replace with this
ORDER BY thread.dateline DESC
Let me know if it works Nordinho, K? ;)
Nordinho
03-22-2005, 06:49 PM
Thanks a lot Tomshawk...works like a charm ;)
Nordinho
03-29-2005, 10:36 AM
One more question ;)...would it be possible to combine 2/3 latest topics in one module (template)??
tomshawk
03-30-2005, 09:56 AM
One more question ;)...would it be possible to combine 2/3 latest topics in one module (template)??
Sorry, I'm not sure what you mean.
Are you asking if you can put these in the same module / block
do you want them seperated by a header of some type to distinguish?
I think I understand, but, no, I wouldn't know how to do it. Sorry
Nordinho
04-05-2005, 03:56 PM
oke, thanks for looking anyways ;)
The Piper
04-17-2005, 03:54 PM
You may also get a random item from the forum you choose by following the original directions by Tomshawk and then changing:ORDER BY lastpost DESC to ORDER BY RAND()
I have been seriously looking for this, thanks for your great hack, Tom! And thanks rbl for this hint on this post (http://www.vbadvanced.com/forum/showpost.php?p=26619&postcount=4). Took me a while to combine the two, but it works like a charm indeed. :)
echarcha
04-20-2005, 04:09 PM
Check out my main page at http://www.echarcha.com
I have used this wonderful hack to note the latest recipes!
tomshawk
04-20-2005, 08:41 PM
Exellent job echarcha, I'm glad you like ;)
Deviant++
04-25-2005, 10:13 PM
gonna try this :D
Deviant++
04-26-2005, 02:14 AM
okay small problem
this isn't happening in latesttopics but the new one.. latest articles..
anyway to get rid of the details ?
tomshawk
04-27-2005, 01:41 AM
okay small problem
this isn't happening in latesttopics but the new one.. latest articles..
anyway to get rid of the details ?
Strange, nothing in my instructions should have caused this.
unless there was a mistake made in step 6
I'd suggest reverting and reapplying the edit
Just for giggles, coule you post the code you have in both instances step 6 and step 2
Deviant++
04-27-2005, 02:16 AM
Strange, nothing in my instructions should have caused this.
unless there was a mistake made in step 6
I'd suggest reverting and reapplying the edit
Just for giggles, coule you post the code you have in both instances step 6 and step 2
okay here we go
<!-- Latest Threads -->
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<thead>
<tr>
<td class="tcat"><span class="smallfont"><strong>$vba_options[portal_blockbullet] <span class="smallfont"><strong>
<if condition="$mods['identifier'] == 'Latest_Articles' ">Latest Articles<else />$vbphrase[latest_forum_topics]</if>
</strong></span></strong></span></td>
</tr>
</thead>
<tr>
<td class="$getbgrow" width="100%">
<A name="scrollingCode"></A><MARQUEE behavior="scroll" align="center" direction="up" height="220" scrollamount="2" scrolldelay="20" onmouseover="this.stop()" onmouseout="this.start()">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
<if condition="$mods['modcol'] == 0">
<tr> <if condition="$vba_options['portal_threads_showicon']">
<td class="thead" width="5"> </td>
</if>
<td class="thead" width="100%"><span class="smallfont">$vbphrase[title_username_date]</span></td>
<if condition="$show['lastpost']">
<td align="center" class="thead" nowrap="nowrap" width="25%"><span class="smallfont">$vbphrase[last_post]</span></td>
</if>
<td class="thead" width="15"><span class="smallfont">$vbphrase[replies]</span></td>
<td class="thead" width="15"><span class="smallfont">$vbphrase[views]</span></td>
<if condition="$vba_options['portal_threads_showforum']">
<td align="center" class="thead" width="10%"><span class="smallfont">$vbphrase[forum]</span></td>
</if> </tr>
</if>$threadbits
</table>
</MARQUEE>
</td>
</tr>
</table>
<br />
<!-- End Latest Threads -->
$threads = $DB_site->query("
SELECT
" . iif($vba_options['portal_threads_showrating'], 'IF(votenum >= ' . $vboptions['showvotes'] . ', votenum, 0) AS votenum, IF(votenum >= ' . $vboptions['showvotes'] . ' AND votenum != 0, votetotal / votenum, 0) AS voteavg,') . "
thread.threadid, thread.title, thread.replycount, postusername, postuserid, thread.dateline AS postdateline, IF(views <= thread.replycount, thread.replycount+1, views) AS views, thread.lastposter, thread.lastpost, pollid
$query[iconfields]
$query[forumfields]
$query[previewfields]
$query[subfields]
FROM " . TABLE_PREFIX . "thread as thread
$query[iconjoin]
$query[forumjoin]
$query[previewjoin]
$deljoin
$query[subjoin]
WHERE open <> '10' AND thread.visible = 1 AND thread.forumid IN(81, 82) $notdeleted
ORDER BY lastpost DESC
LIMIT 5
");
while ($thread = $DB_site->fetch_array($threads))
{
if (strlen($thread['title']) > $vba_options['portal_threads_maxchars'] AND $vba_options['portal_threads_maxchars'])
{
$thread['title'] = fetch_trimmed_title($thread['title'], $vba_options['portal_threads_maxchars']);
}
$thread = process_thread_array($thread, '', $vba_options['portal_threads_showicon']);
$getbgrow = exec_switch_bg();
eval('$threadbits .= "' . fetch_template('adv_portal_latesttopicbits') . '";');
}
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_latesttopics') . '";');
$DB_site->free_result($threads);
unset($thread, $threadbits, $foruminfo, $query, $inforums);
}
?>
tomshawk
04-27-2005, 09:23 AM
Well, I dont see anything wrong in the code. Can you enable the module so we can see it in action.
Maybe make a new page, with everything enabled, and post the link here, so your users wont see it and make comments.
Sorry, and Thanks
Deviant++
04-27-2005, 10:00 AM
the module 'is' enabled, it's at the bottom left hand.
tomshawk
04-27-2005, 10:13 AM
the module 'is' enabled, it's at the bottom left hand.
Strange, It looks more like the archive module then the latest topics module
I'm not sure what to have you try, the code looks right. Sorry
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.