Displaying 'news' as forum-wide 'super-sticky'

Started by Peter Duggan, October 24, 2004, 11:09:05 AM

Previous topic - Next topic

Peter Duggan

Since several people have asked about stickies to display in all boards, here's a quick hack (inspired by two suggestions from Amacythe) to divert items from your forum news to high-visibility 'super-sticky' positions between the link tree and sub-menu on every message index and/or topic page. While it doesn't currently provide any multi-topic cross-board functionality, it has the compensating advantages of being both extremely simple and absolutely non-destructive.

To display a selected news item as 'forum rules' within every topic:

Search sometheme/Display.template.php for:

// Is this topic also a poll?

And add before:

// Show news as 'forum rules'.
echo '
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="bordercolor">
<tr><td style="padding: 1px 1px 0 1px;">
<table width="100%" cellpadding="3" cellspacing="0" border="0">
<tr><td class="windowbg">
<table width="100%" cellpadding="5" cellspacing="0" style="table-layout: fixed;">
<tr>
<td valign="top" width="16%" rowspan="2" style="overflow: hidden;">
<b>Blah (Forum Rules?)</b>
</td>
</tr>
<tr>
<td valign="top" class="windowbg" width="85%">
', $context['news_lines'][0] , '
</td>
</tr>
</table>
</td></tr>
</table>
</td></tr>
<tr><td style="padding: 0 0 1px 0;">
</table>
<br />';



Where Blah (Forum Rules?) explains the purpose of the pseudo-post and $context['news_lines'][0] selects the news item specified by the array key (NB the first item is [0], the second [1] and so on).

To display a selected news item as 'forum rules' within every message index:

Search sometheme/MessageIndex.template.php for:

if (!empty($options['show_board_desc']) && $context['description'] != '')

And add the same new code before (retaining or changing the array key as appropriate to retain or change the news item from the previous example).

Note that these hacks are not mutually dependent and will still work if you disable news from your Current Theme's Settings (so obviating the need to hack any more templates to remove the normal news display), but you'll need to limit the news display to one item instead of a random selection if you also want to use it as originally intended for 'news'. So search sometheme/index.template.php for:

$context['random_news_line']

And replace it with:

$context['news_lines'][0]

Where $context['news_lines'][0] again selects the news item specified by the array key, which I'd normally expect to be different from that chosen for either of the two previous examples. So I'd suggest something like this:

$context['news_lines'][0] (first news item) for normal news.
$context['news_lines'][1] (second news item) for board level rules.
$context['news_lines'][2] (third news item) for topic level rules.

FaSan

Uhmmm... i'm interested at one (or more) thread visible in all board...

If you have a time for it... my time is little now :)


Thanks



FaSan

Jerry

I was thinking about something like a "Global Sticky" that shows in all boards :P


- Jerry
Find me on:
Facebook
Twitter
PlanetSMF

"If all you look for is the negative in things, you will never see the positive."

Amacythe

If I'm not mistaken this will work as a global sticky and show on all boards.  It will not be within the actual board but on top of the category name.

Peter Duggan

Yes, that's basically correct except that it's permanently 'open' and you can't reply to it because it's not a true topic. So the MessageIndex.template.php hack is effectively a global super-sticky and the Display.template.php hack an 'in your face' topic level version, but they're more suited to short announcements than long discourses because you can't close them.

Vinspire

Sorry for digging up this old topic but what is this trick suppose to do ?

geezmo

Are the codes in the first post still applicable in 1.1RC2?

etdwh

The code above does not work correctly for version 1.1 RC2. I guess because of the theme the code above is taken from.

Here is my version, for the default theme in version 1.1 RC2

In MessageIndex.template.php, search for:
if (!empty($options['show_board_desc']) && $context['description'] != '')

add the following above it:

//add rules
echo '
<div class="tborder" style="width: 100%;">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr>
<td width="100%" colspan="7" class="catbg3">Global Announcements</td>
</tr>
' ;
foreach ($context['news_lines'] as $news)
{
echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="5%"><img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%"><img src="', $settings['images_url'], '/post/exclamation.gif" alt="" /></td>
<td class="windowbg3" valign="middle" colspan="5"><b>', $news, '</b></td>
</tr> ';
}
echo '

</table>
</div><br><br> ';
//end add rules


This shows ALL the news items as seperate topics.

Problems:

  • column for topic icon and post icon is slightly bigger than actual post below it, would be nice if i can make it the same. Not sure why the size is different though
  • shows all news items, would be lovely if i can choose which item to display for different boards. Im not a php programmer btw, just done java and jsp's so far, so its not easy for me to figure this out in php :D

It works for me so far, im not sure if this will cause any other problems later.
Just to share, hopefully it will be useful to someone.  ;)

PrizeLive.com

Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

etdwh

Actually, its available as a mod now. Check out the work done by Jay here:
http://www.simplemachines.org/community/index.php?topic=93129

The download is on page 3, but read the other posts, just so you know what you are getting into  ;)

PrizeLive.com

Get Paid Instantly via PayPal (or other options) at PrizeLive.com!

etdwh

Quote from: SurfExcelerator.com on July 19, 2006, 08:36:13 AM
It's not a mod yet though, is it.?

It IS a mod, but a mod in progress  :)
You cant get it from the mods section yet. But if need something now, you could use the currently available "beta". I think it works pretty well, with a minor bug or 2, but does not cause any problems for me so far

pongsak

Quote from: etdwh on July 05, 2006, 04:15:46 AM


//add rules
echo '
<div class="tborder" style="width: 100%;">
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="bordercolor">
<tr>
<td width="100%" colspan="7" class="catbg3">Global Announcements</td>
</tr>
' ;
foreach ($context['news_lines'] as $news)
{
echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="5%"><img src="', $settings['images_url'], '/topic/normal_post.gif" alt="" /></td>
<td class="windowbg2" valign="middle" align="center" width="4%"><img src="', $settings['images_url'], '/post/exclamation.gif" alt="" /></td>
<td class="windowbg3" valign="middle" colspan="5"><b>', $news, '</b></td>
</tr> ';
}
echo '

</table>
</div><br><br> ';
//end add rules


This shows ALL the news items as seperate topics.


but when no any news , it still show news announcement.
Then i add the code after // add rules
if ($context['news_lines']!==array('')){
and } before //end rules.

Then if no news , no show.
smf 1.1.2 with dilbermc themes.
> 50 mods installed.

popomovies


Bulakbol

There's a Global Announcement mod that work with 1.1.3. It might work with 1.1.5.
http://custom.simplemachines.org/mods/index.php?mod=419
Please do not PM me for support · My Mods and Theme · SMF Coding Guidelines · Modifications Approval Guidelines


nickysam

I'm new to this. I dont have any idea regarding this topic.
-----------------
Nickysam

hxxp:www.fastrealestate.net [nonactive]

SpectroPro

Any chance of this being made a mod for 2.x??  I wish super-sticky were just built in..  It's a GREAT idea and could be turned on or off...  Great for announcing a prize winner or special upcoming event.
Stats:  SMF v. 2b4  -  Mambo v4.65  -  Bridge v2.0b1

http://www.therealityrocks.com    http://forum.therealityrocks.com/trr
- Greg

johnsimmons

Hi everyone...I am John from Mexico..I have seen your forum...Nice information provided here which is very useful to everyone....I am not a php programmer between, just done java and jsp's so far,so its not easy for me to figure this out in php.thanks for posting...Let me know more about this.....
==================================================================
simmons
hxxp:auctions.fastrealestate.net [nonactive]

Nathaniel

@johnsimmons,
Do you need any help with this tip? You can always use the mod.

Also, there is a 'Scripting Help' board where you can get help with/learn more about PHP. :)

@SpectroPro,
Hopefully it will be updated when SMF 2 has been around for longer. Remember that you could always ask the mod author about that in the support/comments topic for that mod.
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Advertisement: