PDA

View Full Version : Announcements Section...


TheMusicMan
Sat 10th Apr '04, 8:26am
On an excellent vB site I visit regularly - there is a section called 'latest announcements' - which includes several different coloured announcements that can be either left or right aligned within the section etc... Is this a MOD or am I able to do this as part of standard vB3 Gold functionality...?

If so, how do I do this please.

See image attached...

Thanks

Jake Bunce
Sat 10th Apr '04, 4:48pm
That is not a standard vB feature.

That is either a hack, custom PHP code in the phpinclude_start template, or they are just directly editing the HTML code in the FORUMHOME template to update the links when new announcements are posted.

What exactly does that feature do? Where is the information coming from? I might be able to help you implement such a feature.

TheMusicMan
Sat 10th Apr '04, 8:00pm
Hi Jake

Not too sure about where the information comes from in that section - it's not my site sorry. The site is www.karma-lab.com/forum (http://www.karma-lab.com/forum) - (an excellent synthesiser site). It looks as though it is a seperate announcements section that simply holds links to threads within the forums. I would like to implement a similar function so would appreciate any help you might be able to offer.

So, to start - would I need to edit the phpinclude_start template as you sugest..? and what would be the code code required for linking to a thread.. is it the normal link as seen in the address bar when viewing a specific link...?

Ta

Jake Bunce
Sun 11th Apr '04, 2:06am
If, for example, you have an announcement forum where the only threads posted are announcements, then you can pull the latest thread links from that forum by entering this code into your phpinclude_start template:


if (THIS_SCRIPT == 'index')
{
$threads = $DB_site->query("SELECT threadid, title
FROM " . TABLE_PREFIX . "thread
WHERE forumid=1
ORDER BY threadid
DESC
LIMIT 6");

while ($thread = $DB_site->fetch_array($threads))
{
$threadbits .= "<a href=\"showthread.php?" . $session[sessionurl] . "t=" . $thread[threadid] . "\">" . $thread[title] . "</a><br />";
}
}


Change forumid=1 to whatever forum you want. Change LIMIT 6 to however many threads you want to pull.

Now you can use this code in your FORUMHOME template to display these thread links:


<div class="smallfont">
$threadbits
</div>


This is just an example of how you can dynamically pull this information. This code will give you raw links, no fancy tables or anything.

TheMusicMan
Sun 11th Apr '04, 5:02am
Hey Jake

WOW, that's fantastic - thanks. Let me tell ya, though to most people on here, this code would be extremely straightforward to have thought up, for me, as a total novice to vB and also not being a developer or coder, it's fantastic to be able to achieve something like this. Many thanks to you.

What I am going to to do is create a hidden forum for announcements only - will the information 'pulled' from that forum be available or will it not due to the permissions..? If not, then I shall have a rethink.

Now, the next step for me here is to find out how to contain the output of that code within a similar table/border format to the rest of the site. How would I create a header row with 'Latest Announcements' or similar as the title, and then insert 'LIMIT n' number of threads within that table in the same format as the rest of the site...?

Appreciate your help Jake, thanks.

Jake Bunce
Sun 11th Apr '04, 3:40pm
This code is independant of forum permissions. But if a user clicks a thread link they will need permission to view the thread, otherwise what is the point of linking to it?

For the table code... try this code at the top of your FORUMHOME template:


$stylevar[htmldoctype]
<html 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 -->
<title><phrase 1="$vboptions[bbtitle]">$vbphrase[x_powered_by_vbulletin]</phrase></title>
$headinclude
</head>
<body>
$header
$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat" colspan="2">Announcements</td>
</tr>
<tr>
<td class="alt2"><img src="$stylevar[imgdir_statusicon]/announcement_old.gif" alt="Announcements" border="0" /></td>
<td class="alt1" width="100%">
<div class="smallfont">
$threadbits
</div>
</td>
</tr>
</table>

<!-- main -->
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">

TheMusicMan
Sun 11th Apr '04, 3:55pm
Hey Jake,

Thanks for this - I have installed it and it works just fine. However, re the permissions thing...!

I want to create this 'announcements' section, but I want to pull the announcements from a hidden forum where only Mods and Admins can post. The problem I then have is that when a user clicks on the links that are pulled, they then, as you state, cannot view them...!

Is there a way around this Jake? Or do I need to think of another way of dealing with this. In short, I would like to have an announcements section that everyone can view and read, no-one but Mods and Admin can post in.

Ta for your help so far..

Jake Bunce
Sun 11th Apr '04, 4:03pm
You can edit the forum-level group permissions for your announcements forum so everyone has access but only admins and mods can post new threads. Go to your:

Admin CP -> Forums & Moderators -> Forum Permissions

Edit the permissions for the announcements forum for each group. This part should be self-explanatory. Basically set the viewing permissions to Yes and the posting permissions to No.

You might also want to allow everyone to post replies but only admins and mods to post new threads. This would give users the ability to comment on announcements but not post new ones.

TheMusicMan
Sun 11th Apr '04, 4:28pm
... but wouldn't this then make that forum visible to everyone...?

Jake Bunce
Sun 11th Apr '04, 4:46pm
... but wouldn't this then make that forum visible to everyone...?

Yes. An alternative is to set the permissions like I said in my last post, but make the forum inactive so it doesn't appear.

Admin CP -> Forums & Moderators -> Forum Manager -> Edit Forum -> Forum is Active

Notice the comments for that option, (Will not appear if set to no, but remains accessible if the forum's URL is known).

By using this method, your users will be able to click on the thread links and view the threads, as well as browse the forum's thread listing if they follow the links back from within the forum, but the forum will not appear in any forum listings. So the only way to get into the forum is through the thread links (this applies to admins and mods as well).

Jake Bunce
Sun 11th Apr '04, 4:51pm
And to anticipate what might be your next question...

There is no middle ground on the viewing of the forum. If the forum is active then every group that has the Can View Forum permission enabled for the forum in question will be able to see the forum in the forum listing. If the forum is inactive then no one will see the forum in the forum listing (saying nothing about access to the forum through direct linking). If the forum is active but the Can View Forum permission is set to No then that group will not be able to view anything inside the forum (including direct-linked threads).