PDA

View Full Version : Latest announcement on forum home


tantawi
10-01-2005, 10:00 PM
This is my first hack which I created out of necessity. It's is so simple, it adds "Last Announcement" in the forums home. This is done by selecting the latest thread created in a given forum to be displayed.

See the screenshot attached.

1.2 Update:
- The hack now uses the plugin system, no more code changes ;).

1.1 Update:
- Code is now more optimized, compatible with non-cookied and clustered boards. (Thanks for KirbyDE (https://vborg.vbsupport.ru/showpost.php?p=785462&postcount=8))

1.01 Update:
- Now it works if you use prefix in database.

Enjoy :)

FleaBag
10-02-2005, 08:52 PM
Nice work, I shall most certainly use it. :)

illusions
10-02-2005, 10:03 PM
I get this error when I made the changes...any1 know what the problem is?

Parse error: parse error, unexpected T_WHILE in /home/illusion/public_html/forums/index.php on line 101

thedvs
10-02-2005, 10:42 PM
Works great thanks. *installed*

tantawi
10-03-2005, 04:28 AM
I get this error when I made the changes...any1 know what the problem is?

Parse error: parse error, unexpected T_WHILE in /home/illusion/public_html/forums/index.php on line 101

Are you sure you have vB 3.5 Final installed? I never tested this code on any Betas or RCs. And try the updated hack, as your problem may be with table prefix?

Welcome FleaBag & thedvs :)

swantonio
10-03-2005, 11:15 AM
and possible to have it of different color more and than an announcement

:squareeyed:

Snake
10-03-2005, 01:14 PM
Nice hack. Installed!

Andreas
10-03-2005, 07:34 PM
Some suggestions
- Use Hook forumhome_complete to avoid file edits
- Use query_read instead of just query to avoid overhead and make the hack compatible with splitted (master/slave) mySQL servers
- Use $db->fetch_array instead of mysql_fetch_array() to make the hack compatible with vBulletins Database Abstraction Layer
- The generated link is missing the Session ID ($vbulletin->session->vars['sessionurl']), so it might not work for non-cookied users
- ++$lnsnbsp; seems to be unnecessary

Furthermore, if you just want 1 record, it's easier to use $db->query_first()

Last but not least: A setting to select the Forum ID (rather than having the User edit the Plugin) would be perfect :)

tantawi
10-03-2005, 08:04 PM
Thanks a lot KirbyDE!

I have updated the hack following your suggestions, but I really don't know how to make a plugin and I don't really have time to :(, I'm not considering myself a pro vb coder or something :) just created this little hack out of necessity and liked to share it. Anyone is welcome to port this hack into a plugin without crediting me even :)

Thank you again for your valuable tips.

csidlernet
10-05-2005, 03:13 AM
Thankyou i've been looking for something like this!
/me installs

Alien
10-06-2005, 02:18 AM
So this adds 1 query to forumhome? Or more?

tantawi
10-06-2005, 05:12 AM
So this adds 1 query to forumhome? Or more?

Only one.

vibe
10-10-2005, 03:53 AM
nice work

goodwillstacy
10-14-2005, 06:04 AM
Thanks! I've always wanted something like this... why don't users ever read the annoucement forum, anyway???
But this fixes that...
*goodwillstacy clicks install

JagFan
10-17-2005, 05:05 PM
Thanks! Installed!

Calisse
12-05-2005, 11:09 PM
almost essential for every forum, ive been DESPERATE for this hack! Thank you!

10/10 install it NOW! (easy to use)

tantawi
01-11-2006, 09:59 AM
Updated and now it's a plugin :D

klaush
01-11-2006, 11:03 AM
Updated and now it's a plugin :D

Thanks!

I got a XML-Error when try to install.

tantawi
01-11-2006, 11:14 AM
Thanks!

I got a XML-Error when try to install.

Oh sorry. Fixed by now.

Mr. Bone88
01-13-2006, 07:48 AM
I don't seem to get how this works. I have installed it twice and removed it twice. I can't seem to find where I insert my text for it to appear in the latest announcement area. Where do I go to add my text?

Thanks,
~Mr. Bone88

olli666
02-26-2006, 01:06 PM
I don't seem to get how this works. I have installed it twice and removed it twice. I can't seem to find where I insert my text for it to appear in the latest announcement area. Where do I go to add my text?

Thanks,
~Mr. Bone88

Please, i can't find it too :ermm:

Shaikan
03-20-2006, 12:30 PM
Nice plugin.

But I would need some additional features.
-) I have a multilanguage forum. So I would need that the Announcement changes depending on the forum language (so that I can enter for each language a forum where the last topic is taken for the annoucement).
-) I want that I can change the number of topics displayed in the annoucement field.

zeroality
07-25-2006, 10:12 PM
This is a cool and simple hack. Could use a bit more functionality but I'm going to try to edit that in myself. I'll post the results here if I come up with something good.

zeroality
07-26-2006, 09:34 AM
Edit: Alright, I've been playing around with this. It's probably nothing remarkable but I'm pretty proud of myself as I don't know mySQL or PHP and I had to do this via trial/error and am learning my way around.

This is my first experience in actually coding something in mySQL/php - all I've ever done before was move stuff around or follow file edit instructions.

Anyway - here's what I've gotten so far:
51050

I did all this by editing the plugin code and the template code. Here is what I have for both:

<!-- Latest Announcement -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<thead>
<tr>
<td class="tcat" colspan="2"><a href="http://www.pokerealm.net/forums/forumdisplay.php?f=28">Latest News and Announcements</a></td>
</tr>
</thead>
<tbody id="collapseobj_forumhome_events" style="$vbcollapse[collapseobj_forumhome_events]">
<tr>
<td class="thead" width="3%">&nbsp;</td>
<td class="thead" width="97%">Recent Headlines</td>
<tr>
<td class="alt2" align="center"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/announcement.gif" alt="News Icon"></td>
<td class="alt2">$lns_show</td>
</tr>
<tr>
<td class="alt1" colspan="2"><div class="smallfont">$lns2_show</div></td>
</tr>
<tr>
<td class="alt2" align="center"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/announcement.gif" alt="News Icon"></td>
<td class="alt2">$lnsb_show</td>
</tr>
<tr>
<td class="alt1" colspan="2"><div class="smallfont">$lnsb2_show</div></td>
</tr>
</tbody>
</table>
<!-- /Latest Announcement -->

// ### LATEST NEWS BY TANTAWI ############################################
$latesta = $db->query_first('SELECT title,threadid,views,replycount FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 28 ORDER BY dateline DESC LIMIT 0 , 1');
$lns_show = "<a href=\"showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$latesta[threadid]\">$latesta[title]</a>";
$lns2_show = "<b>Replies:</b> $latesta[replycount] <b>Views:</b> $latesta[views]";
$latesta2 = $db->query_first('SELECT title,threadid,views,replycount FROM ' . TABLE_PREFIX . 'thread WHERE 1 AND forumid = 28 ORDER BY dateline DESC LIMIT 1 , 1');
$lnsb_show = "<a href=\"showthread.php?" . $vbulletin->session->vars['sessionurl'] . "t=$latesta2[threadid]\">$latesta2[title]</a>";
$lnsb2_show = "<b>Replies:</b> $latesta2[replycount] <b>Views:</b> $latesta2[views]";

You can get an idea of how to edit the plugin once you compare my code to the original. Have fun guys.

I plan on adding a lot to this - I'm even thinking of asking someone how to trim phrases in PHP so that I can draw from the database and get the first post then trim it to 150 characters or so and display it right there under the title then a link "Read more...".

-Whoops, didn't mean to double post. I thought it would auto merge my posts.

zeroality
07-27-2006, 05:49 AM
OK, I finally finished tinkering around with it and here is my finished product. If you have any questions, you can PM me. I'm not going to post it as a hack because I don't know how to write the admin CP plugin, etc. My code is probably very inefficient as well.

51182

mshadows
08-18-2006, 04:25 PM
This won't work for 3.6 - anyone have any ideas what changes I need to make to get it working? The Latest Announcement box will show but it's empty even though I have put in the correct forumid.

tantawi
08-18-2006, 05:11 PM
mshadows, It works for me on on 3.6, nothing changed, you may need to rebuild threads info.

Regards.

mshadows
08-18-2006, 07:29 PM
What do you mean by rebuild threads info? Sorry I'm a bit of a newbie with this kind of stuff.

tantawi
08-18-2006, 08:48 PM
From your admincp, select Maintenance > Rebuild thread info.

Regards.

RobbieZ
09-20-2008, 09:45 PM
Anyone got a 3.7.3 version ?

kmoh
02-16-2010, 06:50 AM
Do you have this in 3.8.4?

Christie
02-16-2010, 09:24 AM
Do you have this in 3.8.4?

Yes I use this mod in 3.8.4 - no problems

dexodisc
10-10-2010, 04:17 AM
How can you make this work in vb 4?

What would the variable need to look like?

At the moment it's this:
$lns_show

But Vb 4 has those curly braces. Any ideas?