Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff
Author Message
mass
New Member
New Member



Joined: Mar 05, 2007
Posts: 15

PostPosted: Mon Mar 05, 2007 9:20 am Reply with quote

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
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Mon Mar 05, 2007 5:33 pm Reply with quote

Post the code from the block so that we can see it.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Mon Mar 05, 2007 5:47 pm Reply with quote

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 . '&amp;file=viewtopic&amp;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" />&nbsp;';
      $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 
View user's profile Send private message
mass







PostPosted: Mon Mar 05, 2007 5:57 pm Reply with quote

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 Crying or Very sad

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







PostPosted: Mon Mar 05, 2007 6:05 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 6:09 pm Reply with quote

Block here

Thanks
 
Gremmie







PostPosted: Mon Mar 05, 2007 6:23 pm Reply with quote

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 . '&amp;file=viewtopic&amp;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" />&nbsp;';
      $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







PostPosted: Mon Mar 05, 2007 6:26 pm Reply with quote

mass wrote:
Block here


My code did it all with one SQL query....that one takes 3. Cool
 
mass







PostPosted: Mon Mar 05, 2007 6:27 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 6:28 pm Reply with quote

Also, the code from your block will show posts from private forums. Probably don't want that.... Embarassed

Mine only does public forums.
 
mass







PostPosted: Mon Mar 05, 2007 6:29 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 6:35 pm Reply with quote

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.


Cool

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 . '&amp;file=viewtopic&amp;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" />&nbsp;';
      $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







PostPosted: Mon Mar 05, 2007 6:56 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 7:01 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 7:04 pm Reply with quote

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







PostPosted: Mon Mar 05, 2007 7:10 pm Reply with quote

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. Wink

And no I don't know where you get the quick reply mod.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> General/Other Stuff

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©