Latest Active Topic

Need a hand? Try the *Forum FAQ* link at the top. Failing that, post a question here.
twignberries
New Member
New Member
Posts: 2
Joined: Jul 2003

Latest Active Topic

Postby twignberries » Sun Jun 13 2010, 02:24

Hi guys,
I couldn't find a 'contact us' link so decided to post here.
This is probably a question for the guy who created this board.
Here's hoping the Bladeslapper creator is also a budding rotary enthusiast!

I've created a discussion forum using phpBB3 (don't worry it's not a competing forum).
I was wondering how you've made the "Latest Active Topics" section display at the top of the screen?
I've turned every switch off and on and off again in the Administration Control Panel, the only thing I've achieved is a throbbing great pain in the middle of my forehead.

A little rude for my first post on BS so I've included this little video I made with some nice chopper shots (and not one Robinson to be seen, promise).
Hope it works!

Hmm third edit, try this.
http://www.youtube.com/watch?v=kWvG4J9ESYs
User avatar
Pegs
4th Dan
4th Dan
Posts: 1324
Joined: Dec 2009

Re: Latest Active Topic

Postby Pegs » Sun Jun 13 2010, 02:40

twignberries wrote:Hi guys,
I couldn't find a 'contact us' link so decided to post here.
This is probably a question for the guy who created this board.
Here's hoping the Bladeslapper creator is also a budding rotary enthusiast!

I've created a discussion forum using phpBB3 (don't worry it's not a competing forum).
I was wondering how you've made the "Latest Active Topics" section display at the top of the screen?
I've turned every switch off and on and off again in the Administration Control Panel, the only thing I've achieved is a throbbing great pain in the middle of my forehead.

A little rude for my first post on BS so I've included this little video I made with some nice chopper shots (and not one Robinson to be seen, promise).
Hope it works!

Hmm third edit, try this.
http://www.youtube.com/watch?v=kWvG4J9ESYs


Twignberries,
welcome to BS, for the above request if not already responded too, contact Helothere :D as he is our great leader and provider of this lovely site and will no doubt be able to impart some knowledge as to headache relief! :wink:

Re Video, May I just express my extreme disappointment that you did not include footage of any of Franks fantastic creations :cry: head down for incoming :shock: :lol:
cheers
Pegs 8)
A good idea needs landing gear as well as wings to get off the ground.
User avatar
helothere
Sensei
Sensei
Posts: 1089
Joined: Sep 2005

Re: Latest Active Topic

Postby helothere » Sun Jun 13 2010, 02:56

Hi berries, here's the lowdown:

Add to index.php (in your root) at about line 100:

Code: Select all

////////////////////////////////////////////////////////////////////////////////////////

        /*** phpBB3 - Last Active Topics ***/
        // variables
        define('TOPICS_LIMIT',20); // how many active topics to show
      $posts_per_page = 20; // for pagination
      $timezone = 10; // for time posted
        // Create arrays
        $topics = array();

        // Get forums that current user has read rights to.
        $forums = array_unique(array_keys($auth->acl_getf('f_read', true)));


$sql = "SELECT t.topic_id, t.topic_approved, t.topic_title, t.topic_views, t.topic_replies, t.topic_last_post_id, t.forum_id, t.topic_type, t.topic_status, f.forum_id, p.post_id, p.poster_id,
   p.post_time, u.user_id, u.username, u.user_lastvisit
   FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
   WHERE t.topic_approved = '1' AND " . $db->sql_in_set('t.forum_id', $forums) . "
   AND t.topic_id = p.topic_id
   AND f.forum_id = t.forum_id
   AND t.topic_status <> 2
   AND p.post_id = t.topic_last_post_id
   AND p.poster_id = u.user_id
   ORDER BY t.topic_last_post_id DESC";

if ( !($result = $db->sql_query($sql)) )
{
   message_die(GENERAL_ERROR, 'Could not query recent posts marquee information', '', __LINE__, __FILE__, $sql);
}

if ($row = $db->sql_fetchrowset($result))
{
   $db->sql_freeresult($result);
}

$last_time = ($user->data['user_id'] != ANONYMOUS) ? $user->data['session_last_visit'] : '';
             
for($i = 0; $i <= TOPICS_LIMIT; $i++)
{
   
   $mar_title = $row[$i]['topic_title'];
   $mar_url = $phpbb_root_path . 'viewtopic.'.$phpEx.'?t='.$row[$i]["topic_id"];
   $mar_user = $row[$i]["username"];
   if ( $row[$i]["topic_status"] == TOPIC_LOCKED)
   {
      if ( $row[$i]["post_time"] > $last_time )
      {
         $pic = '<img src="styles/bs/imageset/topic_unread_locked.gif">';
      }
      else
      {
         $pic = '<img src="styles/bs/imageset/topic_read_locked.gif">';
      }
   }
   else
   {
      if ( $row[$i]["topic_type"] == POST_GLOBAL_ANNOUNCE )
      {
         if ( $row[$i]["post_time"] > $last_time )
         {
            $pic = '<img src="styles/bs/imageset/announce_unread.gif">';
         }
         else
         {
            $pic = '<img src="styles/bs/imageset/announce_read.gif">';
         }
      }
      else if ( $row[$i]["topic_type"] == POST_ANNOUNCE )
      {
         if ( $row[$i]["post_time"] > $last_time )
         {
            $pic = '<img src="styles/bs/imageset/announce_unread.gif">';
         }
         else
         {
            $pic = '<img src="styles/bs/imageset/announce_read.gif">';
         }
      }
      else if ( $row[$i]["topic_type"] == POST_STICKY )
      {
         if ( $row[$i]["post_time"] > $last_time )
         {
            $pic = '<img src="styles/bs/imageset/sticky_unread.gif">';
         }
         else
         {
         $pic = '<img src="styles/bs/imageset/sticky_read.gif">';
         }
      }
      else { if ( $row[$i]["post_time"] > $last_time )
      {
         $pic = '<img src="styles/bs/imageset/forum_unread.gif">'; }else{ $pic = '<img src="styles/bs/imageset/forum_read.gif">';
      }
   }
   
   $row_top_id = $row[$i]["topic_id"];
   
   $result_start = $db->sql_query('SELECT topic_replies FROM ' . TOPICS_TABLE . ' WHERE topic_id = ' . $row_top_id . '');
   $row_start = $db->sql_fetchrow($result_start);
   $total_replies = ($row_start['topic_replies']);
}

   switch (TRUE){
       case ($total_replies == 0):
        $last_post_title = "None";
      $start_page = 0;
      $last_post_count = "No replies to this thread";
       break;
      case ($total_replies == 1):
        $start_page = 1;
      $last_post_title = "Show 1";
      $last_post_count = "Show the reply to this thread";                                 
       break;                 
       case (($total_replies > 1) && ($total_replies <= 5)):
        $last_post_title = "Show $total_replies";
      $start_page = 1;
      $last_post_count = "Show all $total_replies replies to this thread";
       break;
      case ($total_replies > 5):
        $start_page = $total_replies - 4;
      $last_post_title = "Last 5";
      $last_post_count = "Last 5 replies to this thread";                                 
       break;
   }
   
// Make GOTO

if ( ( $total_replies + 1 ) > $posts_per_page )
            {
               $total_pages = ceil( ( $total_replies + 1 ) / $posts_per_page );
               $goto_page = ' [Goto page: ';
               $times = 1;
               for($j = 0; $j < $total_replies + 1; $j += $posts_per_page)
               {
                  $goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?t=" .$row[$i]["topic_id"] . "&start=$j") . '">' . $times . '</a>';
                  if ( $times == 1 && $total_pages > 4 )
                  {
                     $goto_page .= ' ... ';
                     $times = $total_pages - 3;
                     $j += ( $total_pages - 4 ) * $posts_per_page;
                  }
                  else if ( $times < $total_pages )
                  {
                     $goto_page .= ', ';
                  }
                  $times++;
               }
               $goto_page .= ' ] ';
            }
            else
            {
               $goto_page = '';
            }      
//////////////////////////////////////////////////
// trim username to max chars to maintain table layout
 
  if (strlen(html_entity_decode($row[$i]["username"])) <= 15) {
    $trimuser = $row[$i]["username"];
  } else {
  $s2 = substr(html_entity_decode($row[$i]["username"]), 0, 12);
  $s2 .= "...";
  $trimuser = htmlentities($s2);
}

// User specific info - eba
if ($user->data['user_id'] == 846) { // user eba
   $eba_query = $db->sql_fetchrow($db->sql_query('SELECT topic_last_post_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = 2479')); 
    $eba_last = ($eba_query['topic_last_post_id']);
   $eba_link = '<a href="viewtopic.php?f=28&t=2479&p=' . $eba_last . '#p' . $eba_last . '" class="rules">Click here for the latest post in the CHC EBA Thread &nbsp;</a>';
   } else if ($user->data['user_id'] == 1473) { // user eba08
   $eba_query = $db->sql_fetchrow($db->sql_query('SELECT topic_last_post_id FROM ' . TOPICS_TABLE . ' WHERE topic_id = 1570')); 
    $eba_last = ($eba_query['topic_last_post_id']);
   $eba_link = '<a href="viewtopic.php?49&t=1570&p=' . $eba_last . '#p' . $eba_last . '" class="rules">Click here for the latest post in the CHC Engineers EBA Thread &nbsp;</a>';
   } else {
   $eba_link = false;
   }

      
$template->assign_block_vars('marqueerow', array(
   'ICON' => $pic,
   'TOPIC_TITLE' => $row[$i]['topic_title'],
   'TOPIC_URL' => $phpbb_root_path . 'viewtopic.php?f=' . $row[$i]['forum_id'] . '&amp;t=' . $row[$i]['topic_id'] . '&amp;p=' . $row[$i]['topic_last_post_id'],
   'LAST_POST_URL' => append_sid($phpbb_root_path . 'viewtopic.'.$phpEx.'?t='.$row[$i]["topic_id"].'&start='.$start_page.'#'.$row_post_id),
   'LAST_POST_TITLE' => $last_post_title,
   'LAST_POST_COUNT' => $last_post_count,
   'TOPIC_VIEWS' => $row[$i]['topic_views'],
   'TOPIC_REPLIES' => $row[$i]['topic_replies'],
   'USERNAME' => $trimuser,
   'USER_PROF' => append_sid($phpbb_root_path . 'memberlist.'.$phpEx.'?mode=viewprofile&u='.$row[$i]["user_id"]),
   'POST_DATE' => @gmdate('D jS, Hi', $row[$i]["post_time"] + (3600 * $timezone)),
   'TOPICS_LIMIT' => TOPICS_LIMIT,
   
   //Pagination for Marquee
   'GOTO_PAGE' => $goto_page,
   'L_GOTO_PAGE' => $user->lang['Goto_page'])

   );
}

// Add count to new posts link
$sql = 'SELECT COUNT(post_id) as count
    FROM ' . POSTS_TABLE . '
      WHERE post_time > ' . $user->data['user_lastvisit'] . '
    AND poster_id != ' . $user->data['user_id'];

$result = $db->sql_query($sql);
$post_count = $db->sql_fetchfield('count', false, $result);
$db->sql_freeresult($result);


Add to styles/YOUR_TEMPLATE/template/index_body.html (where you want actice topics to appear):

Code: Select all

<div class="forabg">
         <div class="inner"><span class="corners-top"><span></span></span>
         
         
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr class="marqueerowtitle">
        <td colspan="2">{MARQUEE_TOPIC}</td>
        <td width="50">Replies</td>
        <td width="60">Views</td>
        <td width="90">Last Replies</td>
        <td width="130">Last reply by</td>
        <td width="130">last reply date</td>
      </tr>
      <!-- BEGIN marqueerow -->
      <tr class="marqueerow">
        <td width="30" class="marqueerow">{marqueerow.ICON}</td>
        <td class="marqueerow"><a href="{marqueerow.TOPIC_URL}"><b>{marqueerow.TOPIC_TITLE}</b></a>
          {marqueerow.GOTO_PAGE}</td>
        <td class="marqueerowstats">{marqueerow.TOPIC_REPLIES}</td>
        <td class="marqueerowstats">{marqueerow.TOPIC_VIEWS}</td>
        <td class="marqueerowstats"><a href="{marqueerow.LAST_POST_URL}" title="{marqueerow.LAST_POST_COUNT}">{marqueerow.LAST_POST_TITLE}</a></td>
        <td class="marqueerowstats"><a href="{marqueerow.USER_PROF}" title="Click for {marqueerow.USERNAME}'s profile">{marqueerow.USERNAME}</a></td>
        <td class="marqueerowstats">{marqueerow.POST_DATE}</td>
      </tr>
      <!-- END marqueerow -->
    </table>


  <span class="corners-bottom"><span></span></span></div>
      </div>


Should be good to go. Please test first and don't hold me responsible if you break the Internet!
:wink:
twignberries
New Member
New Member
Posts: 2
Joined: Jul 2003

Re: Latest Active Topic

Postby twignberries » Sun Jun 13 2010, 03:20

Thanks for the welcome Pegs and thanks for the info helothere.

I only wish I'd received this type of friendly and fast service from my telecommunications provider.
(Hmm....If Telstra call center workers were pilots, I'd wonder what they'd fly?)

I'll give the code a whirl just as soon as the Panadol have done their job.

Thanks again,

t-n-b
User avatar
Queestce
2nd Dan
2nd Dan
Posts: 347
Joined: Oct 2008

Re: Latest Active Topic

Postby Queestce » Sun Jun 13 2010, 03:33

twignberries wrote:I only wish I'd received this type of friendly and fast service from my telecommunications provider.
(Hmm....If Telstra call center workers were pilots, I'd wonder what they'd fly?)


Almost certainly a manned balloon, just as slow and useless as them... Or is that optus?

Welcome to the forum 8)
User avatar
skypig
4th Dan
4th Dan
Posts: 1705
Joined: Nov 2005

Re: Latest Active Topic

Postby skypig » Sun Jun 13 2010, 06:20

If Telstra call center(sic) workers were pilots, I'd wonder what they'd fly?


My guess: After arranging to meet them at the airport, you’d find that a Pakistani with a Land Yacht would be waiting for you, at a different airport.

Sky "Don't start me on Telcos" Pig 8) 8)

Return to “How do I...”

Who is online

Users browsing this forum: No registered users and 1 guest