Author |
Message |
mass
New Member
Joined: Mar 05, 2007
Posts: 15
|
Posted:
Mon Mar 05, 2007 9:20 am |
|
I've just installed the scroling forums block on my site and is almost exactly what I am looking. Does anyone know how I can make it so it doesn't scroll and just have a certain amount of posts (6 for example) visible? Or even know of a block that would do this?
Thanks for your help |
|
|
|
|
montego
Site Admin
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Mon Mar 05, 2007 5:33 pm |
|
|
|
|
Gremmie
Former Moderator in Good Standing
Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Mon Mar 05, 2007 5:47 pm |
|
There is a forums block that comes with nuke. Did you try it?
Otherwise here is a center block I wrote to display the 10 latest threads.
Code:
<?php
if (!defined('BLOCK_FILE'))
{
Header("Location: ../index.php");
die();
}
global $prefix, $db, $sitename;
$sql = 'SELECT t.topic_id, t.topic_title ' .
"FROM {$prefix}_bbtopics AS t, {$prefix}_bbforums AS f, {$prefix}_bbposts AS p " .
'WHERE t.forum_id = f.forum_id AND f.auth_view = 0 AND p.topic_id = t.topic_id AND p.post_id = t.topic_last_post_id ' .
'ORDER BY p.post_time DESC LIMIT 0, 10';
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) > 0)
{
$forumLink = 'forums.html';
$forumPostLink = $forumLink . '&file=viewtopic&t=';
$content = '<center>Join us in our forums for some lively discussions. Here are the latest forum threads with ' .
'new posts:<br /><br /><table><tr><td>';
while ($row = $db->sql_fetchrow($result))
{
$topicId = intval($row['topic_id']);
$title = filter($row['topic_title'], "nohtml");
$content .= '<img src="images/arrow.gif" border="0" alt="arrow" /> ';
$content .= '<a href="' . $forumPostLink . $topicId . '">' . $title . '</a><br />';
}
$content .= '</td></tr></table></center>';
$content .= "<br /><center><a href=\"$forumLink\"><b>$sitename Forums</b></a><br /><br /></center>";
}
else
{
$content = '<center><i>No forum info available at this time.</i></center>';
}
?>
|
Beware the filter() function is something that got added in the later Nukes so it may not be available depending on your version. You could probably omit it and just have $title = $row['topic_title'];
And for some strange reason the forum software on this site changed one line of code on me. I typed this (minus the spaces)
$forumLink = ' m o d u l e s. p h p ? n a m e = F o r u m s';
But it got changed to this:
$forumLink = 'forums.html';
Why? |
_________________ GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module |
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 5:57 pm |
|
I managed to get your code to work Gremmie but I'm looking for one with the author and time of the post aswell as the parent board.
for some reason, when I try to paste th code from the scroll forums block, I get a warning saying I'm attempting to hack the site or something so I can't put it up here
Also, I am looking for a quick reply and notice this site has one. any ideas where I can get it as that would be ideal too. the ones I have used thus far haven't worked |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:05 pm |
|
I actually modified my Top 10 module to include the top 10 recent forum posts, and I have the time in there, but not the author. It shouldn't be too hard to hack into.
However, save your block as a .txt file somewhere on your site and post a link to it here. |
|
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 6:09 pm |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:23 pm |
|
Here is a modified version of my center block, this time with author name and date of post. Tweak to your tastes.
Code:
<?php
if (!defined('BLOCK_FILE'))
{
Header("Location: ../index.php");
die();
}
global $prefix, $db, $sitename;
$sql = 'SELECT t.topic_id, t.topic_title, p.post_time, u.username ' .
"FROM {$prefix}_bbtopics AS t, {$prefix}_bbforums AS f, {$prefix}_bbposts AS p, {$prefix}_users as u " .
'WHERE t.forum_id = f.forum_id AND f.auth_view = 0 AND p.topic_id = t.topic_id AND p.post_id = t.topic_last_post_id ' .
'AND p.poster_id = u.user_id ' .
'ORDER BY p.post_time DESC LIMIT 0, 10';
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) > 0)
{
$forumLink = 'forums.html';
$forumPostLink = $forumLink . '&file=viewtopic&t=';
$content = '<center>Join us in our forums for some lively discussions. Here are the latest forum threads with ' .
'new posts:<br /><br /><table><tr><td>';
while ($row = $db->sql_fetchrow($result))
{
$topicId = intval($row['topic_id']);
$title = $row['topic_title'];
$time = strftime('%H:%M:%S %m/%d/%Y', intval($row['post_time']));
$uname = $row['username'];
$content .= '<img src="images/arrow.gif" border="0" alt="arrow" /> ';
$content .= '<a href="' . $forumPostLink . $topicId . '">' . $title . '</a> by ' . $uname .
' on ' . $time . '<br />';
}
$content .= '</td></tr></table></center>';
$content .= "<br /><center><a href=\"$forumLink\"><b>$sitename Forums</b></a><br /><br /></center>";
}
else
{
$content = '<center><i>No forum info available at this time.</i></center>';
}
?>
|
(It is still changing that one line of code as I noted earlier) |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:26 pm |
|
My code did it all with one SQL query....that one takes 3. |
|
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 6:27 pm |
|
That is brilliant. Would it also be possible to add the forum which it is posted in. The child forum, not the parent.
Also, any ideas on where I can get the quick reply mod that is featured on this site as I haven't had any luck with the others I have found
Thanks a lot for your help-much appreciated |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:28 pm |
|
Also, the code from your block will show posts from private forums. Probably don't want that....
Mine only does public forums. |
|
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 6:29 pm |
|
I'd like to be able to see the private forum if you have the priveldges but obviously not if you don't. Not sure if this is possible |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:35 pm |
|
mass wrote: | That is brilliant. Would it also be possible to add the forum which it is posted in. The child forum, not the parent. |
Code:
<?php
if (!defined('BLOCK_FILE'))
{
Header("Location: ../index.php");
die();
}
global $prefix, $db, $sitename;
$sql = 'SELECT t.topic_id, t.topic_title, p.post_time, u.username, f.forum_name ' .
"FROM {$prefix}_bbtopics AS t, {$prefix}_bbforums AS f, {$prefix}_bbposts AS p, {$prefix}_users as u " .
'WHERE t.forum_id = f.forum_id AND f.auth_view = 0 AND p.topic_id = t.topic_id AND p.post_id = t.topic_last_post_id ' .
'AND p.poster_id = u.user_id ' .
'ORDER BY p.post_time DESC LIMIT 0, 10';
$result = $db->sql_query($sql);
if ($db->sql_numrows($result) > 0)
{
$forumLink = 'forums.html';
$forumPostLink = $forumLink . '&file=viewtopic&t=';
$content = '<center>Join us in our forums for some lively discussions. Here are the latest forum threads with ' .
'new posts:<br /><br /><table><tr><td>';
while ($row = $db->sql_fetchrow($result))
{
$topicId = intval($row['topic_id']);
$title = $row['topic_title'];
$time = strftime('%H:%M:%S %m/%d/%Y', intval($row['post_time']));
$uname = $row['username'];
$fname = $row['forum_name'];
$content .= '<img src="images/arrow.gif" border="0" alt="arrow" /> ';
$content .= '<a href="' . $forumPostLink . $topicId . '">' . $title . '</a> by ' . $uname .
' in ' . $fname . ' on ' . $time . '<br />';
}
$content .= '</td></tr></table></center>';
$content .= "<br /><center><a href=\"$forumLink\"><b>$sitename Forums</b></a><br /><br /></center>";
}
else
{
$content = '<center><i>No forum info available at this time.</i></center>';
}
?>
|
Again, change that $forumLink = line as noted above. The lines are starting to get long now so I would probably chop off the seconds from the time. And maybe make the forum name in bold text. But this should get you started. |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 6:56 pm |
|
I ended up changing my $time = line to the following:
Code:
$time = strftime('%I:%M %p %b %d', intval($row['post_time']));
|
I dropped the seconds, and switched from 24 to 12 hour time. Also dropped the year and switched to a month abbreviation. My forums are pretty active, no need to show the year. LOL. |
|
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 7:01 pm |
|
How about having the name and the board in bold to make those stand out. Liking the 12 hour timings btw
Feels like we're nearly there. How easy would it be to make so you can see the messages on the board that you have permission to see but not those you don't? |
|
|
|
|
mass
|
Posted:
Mon Mar 05, 2007 7:04 pm |
|
Managed to work out where to put the bold tags
Oh and do u know where I can get the quick reply for this forum Gremmie? |
|
|
|
|
Gremmie
|
Posted:
Mon Mar 05, 2007 7:10 pm |
|
mass wrote: |
Feels like we're nearly there. How easy would it be to make so you can see the messages on the board that you have permission to see but not those you don't? |
That would be harder. You'd have to do an is_user() check probably, then figure out what forum groups that person is in, then filter by that. Not something I could do in an evening or something I'd really want for my site. It would be a very complicated block. It's extra credit.
And no I don't know where you get the quick reply mod. |
|
|
|
|
|