| Can someone with programming expertise help me convert this module (which displays my SMF forum's latest posts) into a table format? Currently, the latest forum posts display in a single line, or single sentence; what i'd like to do is break each category up into a table format, so viewing will be easier and look better... Here's the script (it's joomlahacks.com's mod_smf_recenttopics). Thanks for your help in advance. Code: <?php /* tabstop=4 tabreplace=space */ /** * Joomla-SMF Recent Topics * * This file's purpose is to query the SMF database and then create * a list of Recent Topics for display as a module * * LICENSE: This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Module * @package mod_smf_recenttopics * @author Cowboy <ross@joomlahacks.com> * @author Wolverine <joshualross@gmail.com> * @copyright (C) JoomlaHacks.com. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version $Id: mod_smf_recenttopics.php 46 2006-12-01 02:40:05Z joshualross $ * @revision $LastChangedRevision: 46 $ * @date $LastChangedDate: 2006-11-30 21:40:05 -0500 (Thu, 30 Nov 2006) $ * @file $HeadURL: http://scm.joomla.org/svn/repos/joomla-smf_recent_topics/mod_smf_recenttopics.php $ * @link http://www.JoomlaHacks.com * @since File available since Release 2.0 * * Visit JoomlaHacks.com for more Joomla Hacks! */ /* no direct access */ defined( '_VALID_MOS' ) or die( 'Restricted Access.' ); global $database, $mainframe; global $context, $txt, $settings, $user_info, $modSettings; /* 1.5 params-get() second parameter is a default (-Wolverine)*/ //These defaults are identical to the defaults set in mod_smf_recent_topics.xml $moduleclass_sfx = $params->get( 'moduleclass_sfx', '' ); $bln_icon = $params->get( 'bln_icon', 0 ); $bln_board = $params->get( 'bln_board', 0 ); $int_num_topics = $params->get( 'int_num_topics', 5 ); $bln_date_time = $params->get( 'bln_date_time', 0 ); $int_num_char = $params->get( 'int_num_char', 10 ); $bln_real_name = $params->get( 'namedisplay', 0 ); $marquee_scroll = $params->get( 'marquee_scroll', 0 ); $scroll_amount = $params->get( 'scroll_amount', 1 ); $scroll_delay = $params->get( 'scroll_delay', 2 ); $scroll_pause = $params->get( 'scroll_pause', 1 ); $scroll_height = $params->get( 'scroll_height', 200 ); $bln_replies = $params->get( 'bln_replies', 1 ); $bln_poster = $params->get( 'bln_poster', 1 ); $external = $params->get( 'external', 0); //2.0 first, get the class object, then use it to load the params $jsmf =& jsmfFrontend::singleton(); $jsmfConfig = jsmfFrontend::loadParams(); /*1.6.2 Get the ID_MEMBER using $user_info['username'] (-Wolverine)*/ /*1.7.1 Check if not guest and if ID_MEMBER isn't set */ if(!$user_info['is_guest'] && (!isset($ID_MEMBER) || empty($ID_MEMBER))) { $query = "SELECT ID_MEMBER " . "FROM {$jsmfConfig->smf_prefix}members " . "WHERE memberName = '".$user_info['username']."'"; $database->setQuery($query); $row = null; $database->loadObject($row); if (!empty($row)) { $ID_MEMBER = $row->ID_MEMBER; } else { echo "Error fetching ID_MEMBER: ".$database->getErrorMsg(); return false; } } $exclude_boards = array(); $output_method = 'echo'; $query = "SELECT mem.realName, m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName, t.numReplies, t.ID_LAST_MSG, IFNULL(mem.realName, m.posterName) AS posterName, " . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : ' IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= m.ID_MSG_MODIFIED AS isRead, IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ", LEFT(m.body, 384) AS body, m.smileysEnabled, m.icon FROM ({$jsmfConfig->smf_prefix}messages AS m, {$jsmfConfig->smf_prefix}topics AS t, {$jsmfConfig->smf_prefix}boards AS b, {$jsmfConfig->smf_prefix}messages AS ms) LEFT JOIN {$jsmfConfig->smf_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? " LEFT JOIN {$jsmfConfig->smf_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER) LEFT JOIN {$jsmfConfig->smf_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . " WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($int_num_topics, 5)) . " AND t.ID_LAST_MSG = m.ID_MSG AND b.ID_BOARD = t.ID_BOARD" . (empty($exclude_boards) ? '' : " AND b.ID_BOARD NOT IN (" . implode(', ', $exclude_boards) . ")") . " AND $user_info[query_see_board] AND ms.ID_MSG = t.ID_FIRST_MSG ORDER BY t.ID_LAST_MSG DESC LIMIT $int_num_topics"; $database->setQuery($query); $result = null; $result = $database->query(); if (!empty($result)) { $posts = array(); while ($row = mysql_fetch_assoc($result)) { // Censor the subject. censorText($row['subject']); // Build the array. $posts[] = array( 'board' => array( 'id' => $row['ID_BOARD'], 'name' => $row['bName'], 'href' => $jsmf->fixLink('index.php?board=' . $row['ID_BOARD'] . '.0'), 'link' => '<a href="'.$jsmf->fixLink('index.php?board=' . $row['ID_BOARD'] . '.0').'">' . $row['bName'] . '</a>' ), 'topic' => $row['ID_TOPIC'], 'member' => array( 'username' => $row['posterName'], 'name' => $row['realName'], 'id' => $row['ID_MEMBER'], 'href' => !empty($row['ID_MEMBER']) ? $jsmf->fixLink('index.php?action=profile;u=' . $row['ID_MEMBER']) : '', 'link' => !empty($row['ID_MEMBER']) ? '<a href="' .$jsmf->fixLink('index.php?action=profile;u=' . $row['ID_MEMBER']) . '" title="' . $txt[92] . ' ' . $row['posterName'] . '" '. ($external) ? 'target="_blank" ' : '' . '>' . ($bln_real_name ? $row['realName'] : $row['posterName']) . '</a>' : ($bln_real_name ? $row['realName'] : $row['posterName']) ), 'subject' => $row['subject'], 'short_subject' => strlen(un_htmlspecialchars($row['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 0, 22) . '...') : $row['subject'], 'time' => timeformat($row['posterTime']), 'timestamp' => $row['posterTime'], // 'href' => $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new'), 'href' => $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new'), // 'link' => '<a href="' . $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . '#new') . '">' . $row['subject'] . '</a>', 'link' => '<a href="' . $jsmf->fixLink('index.php?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new') . '">' . $row['subject'] . '</a>', /* 1.6 Use the msg id to determine if the post is new (-Wolverine)*/ 'new' => !empty($row['isRead']), 'new_from' => $row['new_from'], 'replies' => $row['numReplies'], //images_url is the url to the theme that is selected for the site. Alternative is default_images_url which is the default theme. 'icon' => '<img src="' . $settings['images_url']. '/post/' . $row['icon'] . '.gif" alt="' . $row['icon'] . '" border="0" />' ); } } else { echo "Error fetching Recent Topics: ".$database->getErrorMsg(); return false; } // Just return it. /* 1.5 Use strcmp, much better method for string comparisons (-Wolverine)*/ if (strcmp($output_method, 'echo') != 0 || empty($posts)) { return $posts; } /* 1.5 PHPNuke marquee scrolling (-Wolverine)*/ //PHPNuke scrolling adapted from Forums Scroll V2 //Original Author: Telli //E-mail: telli@codezwiz.com //Home Page: www.Codezwiz.com //if($bln_marquee_scroll) { // echo '<marquee behavior="scroll" direction="',$str_scroll_direction,'"', ($int_scroll_amount != 0 ? " scrollamount=\"$int_scroll_amount\"" : ""),'',($int_scroll_delay != 0 ? " scrolldelay=\"$int_scroll_delay\"" : ""),' onmouseover=\'this.stop()\' onmouseout=\'this.start()\'>'; //} if ($marquee_scroll) { /* <style type="text/css"> #marqueecontainer{ /*position: relative; * /*width: 200px; marquee width * /*height: 200px; marquee height * /*background-color: white;* overflow: hidden; /*border: 3px solid orange;* padding: 2px; /*padding-left: 4px;* } </style>*/ echo ' <script type="text/javascript"> /*********************************************** * Cross browser Marquee II- Dynamic Drive (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit http://www.dynamicdrive.com/ for this script and 100s more. ***********************************************/ var delayb4scroll='.($scroll_delay*1000).' //Specify initial delay before marquee starts to scroll on page (2000=2 seconds) var marqueespeed='.$scroll_amount.' //Specify marquee scroll speed (larger is faster 1-10) var pauseit='.$scroll_pause.' //Pause marquee onMousever (0=no. 1=yes)? var copyspeed = marqueespeed var pausespeed = (pauseit == 0) ? copyspeed : 0 var actualheight = \'\' function scrollmarquee(){ if (parseInt(cross_marquee.style.top) > (actualheight*(-1)+8)) { cross_marquee.style.top = parseInt(cross_marquee.style.top)-copyspeed+"px" } else { cross_marquee.style.top = parseInt(marqueeheight)+8+"px" } } function initializemarquee(){ cross_marquee=document.getElementById("vmarquee") cross_marquee.style.top=0 marqueeheight=document.getElementById("marqueecontainer").offsetHeight actualheight=cross_marquee.offsetHeight //if Opera or Netscape 7x, add scrollbars to scroll and exit if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ cross_marquee.style.height = marqueeheight+"px" cross_marquee.style.overflow = "scroll" return } setTimeout(\'lefttime=setInterval("scrollmarquee()",30)\', delayb4scroll) } if (window.addEventListener) { window.addEventListener("load", initializemarquee, false) } else if (window.attachEvent) { window.attachEvent("onload", initializemarquee) } else if (document.getElementById) { window.onload=initializemarquee } </script> <div id="marqueecontainer" onmouseover="copyspeed=pausespeed" onmouseout="copyspeed=marqueespeed" style="position: relative; height: '.$scroll_height.'px; overflow: hidden; padding: 2px;"> <div id="vmarquee" style="position: absolute; width: 98%;">'; } echo '<ul class="latestnews',$moduleclass_sfx,'"> '; foreach ($posts as $post) { // $post['href'] = removeTrailingSlash($post['href']); // $post['member']['link'] = removeTrailingSlash($post['member']['link']); echo "\n"; echo '<li class="latestnews'.$moduleclass_sfx.'">'; //This section is done this way(very explicit) so that //future options can be built into the module easier //Start subject link echo '<a class="latestnews'.$moduleclass_sfx.'" href="'.$post['href'].'" '; //external links if ($external) { echo 'target="_blank" '; } echo '>'; //let's leave the formatting to our users in the future //1.7-3 Let them display the topic icon. if($bln_icon) { echo $post['icon']; //space echo ' '; } if ($bln_board) { echo '<i>'.$post['board']['name'].'</i> : '; } if(!empty($int_num_char)) { //$subject_chars = str_replace('&', '&', $post['subject']); //$subject_chars = substr($subject_chars, 0, $int_num_char); //$subject_chars = str_replace('&', '&', $subject_chars); //echo $subject_chars; echo substr(html_entity_decode($post['subject']), 0, $int_num_char); if(strlen($post['subject']) > $int_num_char) { echo '...'; } } else { //echo $post['subject']; echo html_entity_decode($post['subject']); } echo '</a>'; if($bln_replies) { //space echo ' '; //output the number of posts for this subject echo '('.$post['replies'].')'; } if($bln_poster) { //space echo ' '; //this is the 'by' in 'by username' echo $txt[525]; //space echo ' '; //member link //echo $post['member']['link']; echo '<a class="latestnews'.$moduleclass_sfx.'" href="'.$post['member']['href'].'" '; //external links if ($external) { echo 'target="_blank" '; } //echo 'title="' . $txt[92] . ' ' . $post['member']['username'] . '" '. //echo '>'; if ($bln_real_name) { echo 'title="' . $txt[92] . ' ' . $post['member']['name'] . '" > '.$post['member']['name'].'</a>'; } else { echo 'title="' . $txt[92] . ' ' . $post['member']['username'] . '" > '.$post['member']['username'].'</a>'; } } if ($bln_date_time) { //space echo ' '; echo '-'; //space echo ' '; echo $post['time']; } if(empty($post['new'])) { //space echo ' '; //link echo '<a href="' . $post['href'] . '" '; if ($external) { echo 'target="_blank" '; } echo '>'; //image echo '<img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" />'; echo '</a>'; } echo '</li>'; } echo '</ul>'; if($marquee_scroll) { echo '</div></div>'; } ?> |
Forum 





Author



Logged





