TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 30, 2024, 10:27:43 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,174
  • Total Topics: 21,220
  • Online today: 147
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 101
  • Total: 101

"recent topics" in SMF style

Started by Lesmond, August 17, 2005, 12:01:38 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

JPDeni

#490
Actually, I did it wrong. Let's try it again:


global $scripturl;
$what=ssi_recentTopics('10', NULL, 'array');

echo '<table border="0" width="100%" cellspacing="1" cellpadding="3" class="bordercolor">';
echo '<tr class="catbg3"><td align="center">Subject</td><td align="center">Board</td><td align="center">Member</td><td align="center">Date & Time</td></tr>';


$bg=false;
foreach ($what as $topic)
{
echo '<tr class="windowbg' , $bg ? '2' : '' , '">';
$bg = !$bg;
    echo '<td valign="middle">', $topic['link'];

    // Is this topic new? (assuming they are logged in!)
    if (!$topic['new'] && $context['user']['is_logged'])
echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';
echo '</td>
<td valign="middle" >', $topic['board']['link'], '</td>';
echo '</td>
<td valign="middle" >', $topic['poster']['link'], '</td>
<td valign="middle" >';
    if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif'))
echo '<a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" border="0" style="float: right;" /></a>';
    echo '<span class="smalltext">', $topic['time'], '</span></td></tr>';
  }

echo '</table>';


I hadn't realized that each table cell had the background set. It's just as easy to set it at the row level. Also, this code is a whole lot more elegant than the previous one.

alhaudhie

yes... tq... very nice upgrade...

Dark_Star

How do you get it to pick up the member Group colors?

JPDeni

It would require rewriting the code, because ssi_recentTopics doesn't include group colors.

Zetan

Quote from: JPDeni on March 29, 2009, 12:58:13 AM
I hadn't seen Zetan's post. Let's see if I can work through his questions.

1. In order to get the topic title to take you to the first post, the link will have to be built instead of just using what SSI.php gives.

Change

echo '<tr><td class="windowbg" valign="middle">', $topic['link'];


to


echo '<tr><td class="windowbg" valign="middle"><a href="' . $scripturl . '?topic=' . $topic['topic']' . $topic['subject'] . '</a>';


2. I'm not sure what the "new" icon does at the moment. If it doesn't act the way you want, you might try changing

      echo '<a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


to


      echo '<a href="', $topic['href'] . '"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="New', $txt[302], '" border="0" align="right", valign="absmiddle"/></a>';


3. I don't know how to align the graphic differently.

4. Good. :)

5. I don't know how to change that problem.

--------------------------------------------------------------

Mrcare, adding a message preview on mouseover would require javascript, which I'm not familiar with. (I didn't want you to think I was just ignoring you.)

Thanks for the reply Deni, seems I missed your reply too. As you know, I'm having internet problems at home and am finding it difficult keeping up with things.

I'll have a proper look over this when I can.

FUBAR

I'm currently using the code posted by J.A.Cortina here.

The "Last Post" column is a little squished and is making 3 lines of text. 

I would like to like to move the last 3 columns to the left and make the "Subject" column smaller.  I've taken a look at the "JAC_Functions.php" file and tried to modify the Full Block width settings but just can't seem to get it right. 

This is the area I'm trying to modify...
    if ($parm['style'] == 'fullblock') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';


If anyone can help it would be greatly appreciated.  :)



JPDeni

If you're going to use percentages for the widths of your table cells, you should be sure that they total 100%. I'm not sure why the first cell spans two columns, but you would probably do better to define your cell widths on a row where there are no colspans.

zapiy

Added this to a php block minus the php code at the top and bottom. Nothing shows on the frontpage.


Quote from: J.A.Cortina on January 09, 2008, 07:21:21 PM
And, finally, the function itself:
<?php

function JAC_RecentTopics($parm = array(), $output 'echo')
{
    global 
$context$settings$scripturl$txt$db_prefix$ID_MEMBER$user_info$modSettings$user_profile$options;
    
$do_query 1;

    
$valid_recent_types = array('last''unreplied''hours''notify''bookmark''started');
    
$valid_array_types = array('X''I''T');
    
$valid_out_styles = array('fullblock''full''condensed''line'); 
    
$valid_sorts = array('last_post''subject''starter''replies''views''first_post');
    
$sort_dirs = array(
        
'last_post' => array('DESC''asc'),
        
'subject' => array('ASC''desc'),
        
'starter' => array('ASC''desc'),
        
'replies' => array('ASC''desc'),
        
'views' => array('ASC''desc'),
        
'first_post' => array('ASC''desc'),
    );

    
$output strtolower($output) != 'array' 'echo' 'array';

    if (!
is_array($parm)) {
        if (
$output 'array') {
            return array();}
        else {
            echo 
'Unexpected argument - expecting parameter array)';
            return; }
    }

if(!empty($options['num_topics_page']))
$modSettings['defaultMaxTopics'] = $options['num_topics_page'];
if(!empty($options['num_posts_page']))
$modSettings['defaultMaxMessages'] = $options['num_posts_page'];

    
$parm['type'] = (isset($parm['type']) && !empty($parm['type']) && in_array(strtolower($parm['type']), $valid_recent_types)) ? strtolower($parm['type']) : $valid_recent_types[0];

    
$parm['count'] = (isset($parm['count']) && !empty($parm['count']) && is_numeric($parm['count'])) ? $parm['count'] : 0;

    
$parm['array_type'] = (isset($parm['array_type']) && !empty($parm['array_type']) && in_array(strtoupper($parm['array_type']), $valid_array_types)) ? strtoupper($parm['array_type']) : $valid_array_types[0];

    
$parm['select_array'] = (isset($parm['select_array']) && !empty($parm['select_array']) && is_array($parm['select_array'])) ? $parm['select_array'] : array();

    
$parm['style'] = (isset($parm['style']) && !empty($parm['style']) && in_array(strtolower($parm['style']), $valid_out_styles)) ? strtolower($parm['style']) : $valid_out_styles[0];

    
$parm['heading'] = (isset($parm['heading'])) ? $parm['heading'] : '';

    
$parm['sort_by_start'] = (isset($parm['sort_by_start']) && ($parm['sort_by_start'] === true)) ? true false;

    
$parm['user_id'] = (isset($parm['user_id']) && !empty($parm['user_id']) && is_numeric($parm['user_id'])) ? $parm['user_id'] : 0;
    
$parm['user_id'] = $parm['user_id'] != $parm['user_id'] : $ID_MEMBER;

    
$parm['start_num'] = (isset($parm['start_num']) && !empty($parm['start_num']) && is_numeric($parm['start_num'])) ? $parm['start_num'] : 0;

    
$parm['sort_col'] = (isset($parm['sort_col']) && !empty($parm['sort_col']) && in_array(strtolower($parm['sort_col']), $valid_sorts)) ? strtolower($parm['sort_col']) : $valid_sorts[0];

    
$parm['sort_dir'] = (isset($parm['sort_dir']) && ((strtoupper($parm['sort_dir']) == 'ASC') || (strtoupper($parm['sort_dir']) == 'DESC'))) ? strtoupper($parm['sort_dir']) : '';
    
$cur_dir $parm['sort_dir'] != '' $parm['sort_dir'] : $sort_dirs[$parm['sort_col']];

    
$parm['save_url_stub'] = (isset($parm['save_url_stub'])) ? $parm['save_url_stub'] : '';

    
$parm['mem_colors'] = (isset($parm['mem_colors']) && ($parm['mem_colors'] === false)) ? false true;

    
$parm['height'] = (isset($parm['height'])) ? $parm['height'] : 0;

    
$parm['per_page'] = (isset($parm['per_page']) && !empty($parm['per_page']) && is_numeric($parm['per_page'])) ? $parm['per_page'] : 0;
    
$parm['per_page'] = $parm['per_page'] > $parm['per_page'] : $modSettings['defaultMaxTopics'];

    
$constraint '';
    if (
$parm['type'] == 'bookmark')
if( mysql_num_rowsmysql_query("SHOW TABLES LIKE '"$db_prefix"bookmarks'") ) == )
            
$parm['type'] == 'notify';

    if ((
$parm['type'] == 'bookmark') || ($parm['type'] == 'notify')) {
    
$watched_topics = array();
        if (
$parm['type'] == 'bookmark')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}bookmarks WHERE ID_MEMBER = {$parm['user_id']}"__FILE____LINE__);
        if (
$parm['type'] == 'notify')
        
$request db_query("SELECT ID_TOPIC FROM {$db_prefix}log_notify WHERE ID_MEMBER = {$parm['user_id']} AND ID_BOARD = 0"__FILE____LINE__);
    
while ($row mysql_fetch_assoc($request))
            
$watched_topics[] = $row['ID_TOPIC'];
mysql_free_result($request);
if (count($watched_topics) == 0)
$do_query 0;
    
else
    
$constraint =' t.ID_TOPIC IN (' implode(', '$watched_topics) . ')';
    }

    
$type_methods = array(
        
'last' =>   ($parm['array_type'] == 'X' ? (($parm['count'] != 0) ? ('t.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - (150 max($parm['count'], $parm['per_page'])))) : '1' ) : '1'),
        
'unreplied' => 't.numReplies = 0',
        
'hours' => $parm['count'] == 'ml.posterTime >= ' strtotime('1 day ago') : 'ml.posterTime >= ' strtotime($parm['count'] . ' hours ago'),
        
'notify' => $constraint,
        
'bookmark' => $constraint,
        
'started' => 't.ID_MEMBER_STARTED = ' $parm['user_id'],
    );
    
$type_method_clause $type_methods[$parm['type']];

    
$select_methods = array(
        
'X' => count($parm['select_array']) == '' ' AND b.ID_BOARD NOT IN (' implode(', '$parm['select_array']) . ')',
        
'I' => count($parm['select_array']) == '' ' AND b.ID_BOARD IN (' implode(', '$parm['select_array']) . ')',
        
'T' => count($parm['select_array']) == '' ' AND t.ID_TOPIC IN (' implode(', '$parm['select_array']) . ')',
    );
    
$select_method_clause $select_methods[$parm['array_type']];

    
$sort_methods = array(
    
'last_post' => ($parm['sort_by_start'] ? 't.ID_FIRST_MSG' 't.ID_LAST_MSG'),
    
'subject' => 'ms.subject',
    
'starter' => 'IFNULL(mems.realName, ms.posterName)',
    
'replies' => 't.numReplies',
    
'views' => 't.numViews',
    
'first_post' => 't.ID_TOPIC',
    );
    
$sort_method_clause ' ORDER BY '$sort_methods[$parm['sort_col']] . ' ' . ($parm['sort_dir'] == '' $sort_dirs[$parm['sort_col']][0] : $parm['sort_dir']);

    
$type_heading = array(
   
    'last' => 'Most Recently Posted To Topics',
       
'unreplied' => 'Unreplied To Topics',
        
'hours' => 'Topics Posted To In Last '. ($parm['count'] == 24 $parm['count']) . ' Hours',
        
'notify' => 'Topics Being Watched' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'bookmark' => 'Topics Bookmarked' . ($ID_MEMBER == $parm['user_id'] ? '' : (' by User# ' $parm['user_id'])),
        
'started' => 'Topics Started ' . ($ID_MEMBER == $parm['user_id'] ? ' by You' : (' by User# ' $parm['user_id'])),
    );

$limit_clause $parm['type'] == 'hours' '' : ($parm['count'] == ' LIMIT '.$modSettings['defaultMaxTopics'] : ' LIMIT '.$parm['count']);

$stable_icons = array('xx''thumbup''thumbdown''exclamation''question''lamp''smiley''angry''cheesy''grin''sad''wink''moved''recycled''wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$topics = array();

if ($do_query == 1)
{
$groupcolors = array();
        if (
$parm['mem_colors']) {
    
$request db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups"__FILE____LINE__);
     while ($row mysql_fetch_assoc($request))
     $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
    
mysql_free_result($request);
    
}

        if (
$parm['style'] == 'full') {
$request db_query("
SELECT b.ID_BOARD
FROM 
{$db_prefix}boards AS b
WHERE " 
$user_info['query_see_board'] . (!empty($modSettings['recycle_enable']) && ($modSettings['recycle_board'] > 0) ? "
AND b.ID_BOARD != " 
. (int) $modSettings['recycle_board'] : '') .
$select_method_clause,
__FILE____LINE__);
    
$boards = array();
    
while ($row mysql_fetch_assoc($request))
    
$boards[] = $row['ID_BOARD'];
    
mysql_free_result($request);
    
$query_this_board = empty($boards) ? '' 'WHERE t.ID_BOARD IN (' implode(', '$boards) . ')';

    $request db_query("
    SELECT COUNT(*), MIN(t.ID_LAST_MSG)
       FROM 
{$db_prefix}topics AS t, {$db_prefix}messages AS ml " .
$query_this_board "
AND ml.ID_MSG = t.ID_LAST_MSG " 
.
$select_method_clause "
AND " 
$type_method_clause,
__FILE____LINE__);
    
list ($num_topics$min_message) = mysql_fetch_row($request);
    
mysql_free_result($request);
            
$limit_clause 'LIMIT ' $parm['start_num'] . ', ' $parm['per_page'];
        }

$query "
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
ml.body AS lastBody, ms.body AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from'
) . "
FROM (
{$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN 
{$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN 
{$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN 
{$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " 
$type_method_clause " " .
    $select_method_clause " " .
   "AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD " 
.
(!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > " AND b.ID_BOARD != $modSettings[recycle_board]'') .
   " AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " 
$user_info['query_see_board'] . " " .
$sort_method_clause " " $limit_clause;

$request db_query($query__FILE____LINE__);

$topic_ids = array();
while ($row mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '')));

if ($row['ID_FIRST_MSG'] == $row['ID_LAST_MSG'])
{
$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];
}
        else
        {
    $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '')));
        }

// Decide how many pages the topic should have.
$topic_length $row['numReplies'] + 1;
if ($topic_length $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa 1;
for ($tmpb 0$tmpb $topic_length$tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.' $tmpb ';topicseen">' $tmpa '</a>';
$tmpa++;
}

// Show links to all the pages?
if (count($tmppages) <= 5)
$pages 'Ã,« ' implode(' '$tmppages);
// Or skip a few?
else
$pages 'Ã,« ' $tmppages[0] . ' ' $tmppages[1] . ' ... ' $tmppages[count($tmppages) - 2] . ' ' $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length $modSettings['enableAllMessages'])
$pages .= '  <a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;all">' $txt[190] . '</a>';
$pages .= ' Ãƒ,»';
}
else
$pages '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['firstIcon'] . '.gif') ? 'images_url' 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' $row['lastIcon'] . '.gif') ? 'images_url' 'default_images_url';
}

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' $scripturl '?action=profile;u=' $row['ID_FIRST_MEMBER'] . '" title="' $txt[92] . ' ' $row['firstPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' '' ) : '' )  . $row['firstPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true$row['firstPosterTime']),
'subject' => $row['firstSubject'],
'short_subject' => shorten_subject($row['firstSubject'], 25),
'preview' => shorten_subject($row['firstBody'],128),
'body' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0;topicseen">' $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' $scripturl '?action=profile;u=' $row['ID_LAST_MEMBER'] . '" title="' $txt[92] . ' ' $row['lastPosterName'] . '">' . ( $parm['mem_colors'] ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' '' ) : '' ) . $row['lastPosterName'] . (( $parm['mem_colors'] && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' '' ) . '</a>' $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true$row['lastPosterTime']),
'subject' => $row['lastSubject'],
'short_subject' => shorten_subject($row['lastSubject'], 25),
'preview' => shorten_subject($row['lastBody'],128),
'body' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' $row['lastIcon'] . '.gif',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'],
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['ID_LAST_MSG']) . ';topicseen#msg' $row['ID_LAST_MSG'] . '">' $row['lastSubject'] . '</a>'
),
'new' => !$row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl '?topic=' $row['ID_TOPIC'] . '.msg' $row['new_from'] . ';topicseen#new',
'href' => $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen' . ($row['numReplies'] == '' 'new'),
'link' => '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . ($row['numReplies'] == '.0' '.msg' $row['new_from']) . ';topicseen#msg' $row['new_from'] . '">' $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl '?board=' $row['ID_BOARD'] . '.0',
'link' => '<a href="' $scripturl '?board=' $row['ID_BOARD'] . '.0">' $row['bname'] . '</a>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result db_query("
SELECT ID_TOPIC
FROM 
{$db_prefix}messages
WHERE ID_TOPIC IN (" 
implode(', '$topic_ids) . ")
AND ID_MEMBER = 
$ID_MEMBER"__FILE____LINE__);
while ($row mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if ($output == 'array')
    return $topics;

if ( ($parm['style'] == 'full') || ($parm['style'] == 'fullblock') )
{
if (!empty($topics))
    {

    if ($parm['style'] == 'full') {
        $page_url $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : '');
        $current_page = (int) $parm['start_num'] / $parm['per_page'];
        $links = array(
            'first' => $parm['start_num'] >= $parm['per_page'] ? $scripturl $page_url ';start=0' '',
            'prev' => $parm['start_num'] >= $parm['per_page'] ? $scripturl .  $page_url ';start=' . ($parm['start_num'] - $parm['per_page']) : '',
            'next' => $parm['start_num'] + $parm['per_page'] < $num_topics $scripturl .  $page_url ';start=' . ($parm['start_num'] + $parm['per_page']) : '',
            'last' =>  ( ($parm['start_num'] + $parm['per_page']) < $num_topics) ? ($scripturl .  $page_url ';start=' . (floor(($num_topics 1) / $parm['per_page']) * $parm['per_page']) ) : '',
            'up' => $scripturl,
        );
        
$page_info = array(
            'current_page' => floor($parm['start_num'] / $parm['per_page']) + 1,
        
    'num_pages' => floor(($num_topics 1) / $parm['per_page']) + 1,
                    
'page_index' => constructPageIndex($scripturl $parm['save_url_stub'] . ';sort=' $parm['sort_col'] . ( ($parm['sort_dir'] != '') ? ';'.$parm['sort_dir'] : ''), $parm['start_num'], $num_topics$parm['per_page'], false),
        );

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;
    }

    echo '
        <div class="tborder" '
$context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' 'style="margin:0px;"''>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">'
;


if ($parm['heading'] != 'SUPPRESS') {
    
echo '
<tr>'
;
echo '
<td class="titlebg" colspan="7">'
, ($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']), '</td>';
echo '
</tr>'
;
}

    if ($parm['style'] == 'fullblock') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>'
$txt[70], '
</td><td width="14%">'
$txt[109], '
</td><td width="4%" align="center">'
$txt[110], '
</td><td width="4%" align="center">'
$txt[301], '
</td><td width="24%">'
$txt[111], '
</td>
</tr>'
;
    }

    if ($parm['style'] == 'full') {
        echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>
<a href="'
$parm['save_url_stub'], ';sort=subject', ($parm['sort_col'] != 'subject' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'subject') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="14%">
    <a href="'
$parm['save_url_stub'], ';sort=starter', ($parm['sort_col'] != 'starter' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'starter') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=replies', ($parm['sort_col'] != 'replies' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'replies') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="4%" align="center">
    <a href="'
$parm['save_url_stub'], ';sort=views', ($parm['sort_col'] != 'views' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'views') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td><td width="24%">
    <a href="'
$parm['save_url_stub'], ';sort=last_post', ($parm['sort_col'] != 'last_post' '' : ($parm['sort_dir'] == '' ';order='.$sort_dirs[$parm['sort_col']][1] : '')), '">'$txt[70], (($parm['sort_col'] != 'last_post') ? '' : (' <img src="' $settings['images_url'] . '/sort_' . (($cur_dir == 'DESC') ? 'down' 'up') . '.gif" alt="" border="0" />')), '</a>
</td>
</tr>'
;
    }

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' 
$settings['images_url'] . '/topic/' $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' 
$topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' 
$topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' '' '" width="48%" valign="middle">' $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' '' $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' 
$settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' '';
if ($topic['new'])
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="'$topic['new_href'], '"> <img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="'$txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
  echo '
<span class="smalltext">'
$topic['pages'], '<br>'$txt['smf88'], ' '$topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
'
$topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
'
$topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="'
$topic['last_post']['href'], '"><img src="'$settings['images_url'], '/icons/last_post.gif" alt="'$txt[111], '" title="'$txt[111], '" style="float: right;" /></a>
<span class="smalltext">
'
$topic['last_post']['time'], '<br />
'
$txt[525], ' '$topic['last_post']['member']['link'], '
</span>
</td>
</tr>'
;
}

    echo '</table>';

    echo '</div>';

    if ($parm['style'] == 'full') {

            
echo '
                 <table border="0" width="100%" cellpadding="0" cellspacing="0">
                  <tr>
                  <td class="middletext" valign="middle">' 
$txt[139] . ': ' $page_info['page_index'] . '</td>
                 </tr>
                 </table>'
;

    echo'
<div class="tborder"><div class="titlebg2">
<table cellpadding="8" cellspacing="0" width="55%">
<tr>
<td align="left" style="padding-top: 2ex;" class="smalltext">'
, !empty($modSettings['enableParticipation']) ? '
<img src="' 
$settings['images_url'] . '/topic/my_normal_post.gif" alt="" align="middle" /> ' $txt['participation_caption'] . '<br />' '''
<img src="' 
$settings['images_url'] . '/topic/normal_post.gif" alt="" align="middle" /> ' $txt[457] . '<br />
<img src="' 
$settings['images_url'] . '/topic/hot_post.gif" alt="" align="middle" /> ' $txt[454] . '<br />
<img src="' 
$settings['images_url'] . '/topic/veryhot_post.gif" alt="" align="middle" /> ' $txt[455] . '
</td>
<td align="left" valign="top" style="padding-top: 2ex;" class="smalltext">
<img src="' 
$settings['images_url'] . '/icons/quick_lock.gif" alt="" align="middle" /> ' $txt[456] . '<br />' . ($modSettings['enableStickyTopics'] == '1' '
<img src="' 
$settings['images_url'] . '/icons/' . (!empty($settings['seperate_sticky_lock']) ? 'quick_sticky' 'normal_post_sticky') . '.gif" alt="" align="middle" /> ' $txt['smf96'] . '<br />' '') . ($modSettings['pollMode'] == '1' '
<img src="' 
$settings['images_url'] . '/topic/normal_poll.gif" alt="" align="middle" /> ' $txt['smf43'] : '') . '
</td>
</tr>
</table>
</div>'
;
    }

    }
else
    

    
echo '<b><u>',($parm['heading'] == '' $type_heading[$parm['type']] : $parm['heading']),'<br><br>No Topics Match Search Criteria</u></b>';
    }
}

if ($parm['style'] == 'condensed')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '
<div class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['short_subject'] . ($w['new'] ? '</b>' '') .'</a></div>
<div class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b> ';
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '</div><div class="smalltext">';
echo '['.$w['last_post']['time'].']
</div>'
;

if($counter != $cmax)
echo '<hr />';
$counter++;
}
echo '
</div></div>'
;
}

if ($parm['style'] == 'line')
{
$counter=1$cmax=count($topics);
$height_clause = (isset($parm['height']) && ($parm['height'] > 0) ? ' height: '.$parm['height'].'px;' '');
echo ' <div style="width: 100%;'$height_clause' overflow: auto;">
<div class="windowbg" style="width: 100%; overflow: hidden;">'
;
foreach ($topics as $w)
{
echo '<div class="windowbg'. ((($counter 2) == 0) ? '' '2') . '" style="width: 100%;line-height: 1.4em">';
echo '
<span class="smalltext"><a href="'
.$w['last_post']['href'].'">'. ($w['new'] ? '<b>' '') . $w['last_post']['subject'] . ($w['new'] ? '</b>' '') .'</a>  </span>
<span class="smalltext">(in '
.$w['board']['link'].')  </span>
<span class="smalltext">'
$txt[525], ' <b>'$w['last_post']['member']['link'], '</b>  </span>
<span class="smalltext">'
;
if($w['new'])
echo '<a href="'.$w['new_href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';

echo '['.$w['last_post']['time'].']
</span><br />'
;

$counter++;
echo '
</div>'
;
}
echo '
</div></div>'
;
}

}

?>


IchBin

The instructions for using that code is posted in the post directly before the one you copied that code from. Please read it.
http://www.tinyportal.net/index.php/topic,596.msg173244.html#msg173244

zapiy

#499
Ok i ended up using the JAC_functions.php file and outputting via an article my question is how do you make it so it shows the last 20 posts regardless if you have seen them? We may not have 20 posts everyday but i want the block to remmain the same size whatever..Can that be done?

Cheers