Re: Some advice on my modded Latest Topics

Thanks Matt. it works now. Question: Why is it that when I set it to display 5 it only displays 4. I know it has something to do with the censoring are because if I remove it 5 is 5. Any ideas?

Thanks again.

Re: Some advice on my modded Latest Topics

As a matter of fact Matt. It only displays (4) posts. it doesn't matter what I set it to.

28

Re: Some advice on my modded Latest Topics

It's working fine on test here, so that must be related to something in your setup.

29 (edited by bingiman 2007-11-05 02:02)

Re: Some advice on my modded Latest Topics

Matt, please ignore my last post. I am an idiot. I am counting replies instead of actual posts so that is why it was not showing more than 4. Sorry about that.

Bingiman

30

Re: Some advice on my modded Latest Topics

It makes a change for it not to be me having one of those moments. big_smile

Re: Some advice on my modded Latest Topics

Well, the only thing I changed was the hover over the subject. That was truncated as well but I felt it was better that you could hover over it and see the entire subject line.
Here is the code just in case you wanted it.

<?php

$show = '10';

showRecent($show);

function showRecent($show)
{
    global $lang_common, $db, $pun_config, $pun_user, $db_prefix;
    $max_subject_length = 20;

    $order_by = 't.last_post';
    $forum_sql = '';

    $show = intval($show);

    if ($show > '0')
    {

        // Fetch topics
        $result = $db->query('SELECT t.id, t.poster, t.subject, t.posted, t.last_post FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id=3) WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.moved_to IS NULL '.$forum_sql.' ORDER BY '.$order_by.' DESC LIMIT '.$show) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());

        if ($db->num_rows($result))
        {
            while($cur_topic = $db->fetch_assoc($result))
            {
                if ($pun_config['o_censoring'] == '1')
                {
                    $cur_topic['subject'] = censor_words($cur_topic['subject']);
                }

                if (pun_strlen($cur_topic['subject']) > $max_subject_length)
                {
                    $subject = trim(substr($cur_topic['subject'], 0, ($max_subject_length-5))).'...';
                }
                else
                {
                    $subject = $cur_topic['subject'];
                }
                echo '<br />';
                echo '<div class="l_icon"><strong><a class="l_icon_padding" href="'.$pun_config['o_base_url'].'/viewtopic.php?id='.$cur_topic['id'].'&action=new" title="'.pun_htmlspecialchars($cur_topic['subject']).'">'.pun_htmlspecialchars($subject).'</a></strong></div><br /><div style="padding-left: 12px; font-size: 9px; font-family: Tahoma, Arial, Verdana; text-align: left;">by: '.pun_htmlspecialchars($cur_topic['poster']).'<br />'.format_time($cur_topic['last_post']).'</div>'."\n";
            }
        }
    }
}

?>