son mesajlar yerine son konular

Started by 60CHEVY, January 19, 2009, 01:43:41 PM

Previous topic - Next topic

60CHEVY

Merhabalar,
forum anasayfasının alt kısmında yer alan ve sayısı tarafımızca ayarlanabilen son mesajlar yerine,verilen mesaja ait konu adının yer alması olasımı?
TEŞEKKÜRLER

Badboy

Evet mümkün aşağıdaki işlemleri yaparsanız istediğiniz gibi bir sonuç alırsınız.

Herhangi bir değişiklik yapmadan önce aksi durumlara karşı yedek almayı unutmayın.

  • Görüntülenecek son konuların sayısı sizin daha önce son mesajlar için ayar yaptığınız kısımdan yapılacaktır.
  • Çalışması için sayının 1 (bir) den fazla olması gerekmektedir. Aksi halde en son mesaj görünecektir.

    Öncelikle Sources/Recent.php dosyasını açın.

    Code (ŞUNU BULUN) Select
    // Find unread topics and replies.
    function UnreadTopics()


    Code (ÖNCESİNE EKLEYİN) Select
    function getLastTopics($showlatestcount)
    {
    global $settings, $scripturl, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $func;

    $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';

    // Find all the posts in distinct topics.  Newer ones will have higher IDs.
    $request = db_query("
    SELECT
    m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG, b.ID_BOARD, b.name AS bName,
    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 ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)
    LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (!$user_info['is_guest'] ? "
    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 = b.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)" : '') . "
    WHERE t.ID_LAST_MSG >= " . ($modSettings['maxMsgID'] - 35 * min($showlatestcount, 5)) . "
    AND t.ID_LAST_MSG = m.ID_MSG
    AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
    AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
    AND $user_info[query_see_board]
    AND ms.ID_MSG = t.ID_FIRST_MSG
    ORDER BY t.ID_LAST_MSG DESC
    LIMIT $showlatestcount", __FILE__, __LINE__);
    $posts = array();
    while ($row = mysql_fetch_assoc($request))
    {
    // Censor the subject.
    censorText($row['subject']);
    censorText($row['body']);

    $row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
    if ($func['strlen']($row['body']) > 128)
    $row['body'] = $func['substr']($row['body'], 0, 128) . '...';

    if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
    $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.gif') ? 'images_url' : 'default_images_url';

    // Build the array.
    $posts[] = array(
    '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>'
    ),
    'topic' => $row['ID_TOPIC'],
    'poster' => array(
    'id' => $row['ID_MEMBER'],
    'name' => $row['posterName'],
    'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
    'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
    ),
    'subject' => $row['subject'],
    'short_subject' => shorten_subject($row['subject'], 25),
    'preview' => $row['body'],
    'time' => timeformat($row['posterTime']),
    'timestamp' => forum_time(true, $row['posterTime']),
    'raw_timestamp' => $row['posterTime'],
    'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#new',
    'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#new">' . $row['subject'] . '</a>',
    'new' => !empty($row['isRead']),
    'new_from' => $row['new_from'],
    'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.gif" align="middle" alt="' . $row['icon'] . '" border="0" />',
    );
    }
    mysql_free_result($request);

    return $posts;
    }


    Şimdi Sources/BoardIndex.php dosyasını açın.

    Code (ŞUNU BULUN) Select
    // We have to clean up the cached data a bit.
    foreach ($context['latest_posts'] as $k => $post)
    {
    $context['latest_posts'][$k]['time'] = timeformat($post['raw_timestamp']);
    $context['latest_posts'][$k]['timestamp'] = forum_time(true, $post['raw_timestamp']);
    }


    Code (SONRASINA EKLEYİN) Select

    if (($context['latest_topics'] = cache_get_data('boardindex-latest_topics:' . md5($user_info['query_see_board'] . $user_info['language']), 180)) == null)
    {
    $context['latest_topics'] = getLastTopics($settings['number_recent_posts']);
    cache_put_data('boardindex-latest_topics:' . md5($user_info['query_see_board'] . $user_info['language']), $context['latest_posts'], 180);
    }

    // We have to clean up the cached data a bit.
    foreach ($context['latest_topics'] as $t => $topic)
    {
    $context['latest_topics'][$t]['time'] = timeformat($topic['raw_timestamp']);
    $context['latest_topics'][$t]['timestamp'] = forum_time(true, $topic['raw_timestamp']);
    }


    Son olarak Themes/TEMAMIZ/BoardIndex.template.php dosyasını açın.

    Not: Aşağıdaki değişiklik default temaya göre yapılmıştır

    Code (ŞUNU BULUN) Select
    // Show lots of posts.
    elseif (!empty($context['latest_posts']))
    {
    echo '
    <table cellpadding="0" cellspacing="0" width="100%" border="0">';

    /* Each post in latest_posts has:
    board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
    subject, short_subject (shortened with...), time, link, and href. */
    foreach ($context['latest_posts'] as $post)
    echo '
    <tr>
    <td class="middletext" valign="top"><b>', $post['link'], '</b> ', $txt[525], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</td>
    <td class="middletext" align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
    </tr>';
    echo '
    </table>';
    }


    Code (ŞUNUNLA DEĞİŞTİRİN) Select
    // Show lots of topics.
    elseif (!empty($context['latest_topics']))
    {
    echo '
    <table cellpadding="0" cellspacing="0" width="100%" border="0">';

    /* Each post in latest_topics has:
    board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
    subject, short_subject (shortened with...), time, link, and href. */
    foreach ($context['latest_topics'] as $post)
    echo '
    <tr>
    <td class="middletext" valign="top"><b>', $post['link'], '</b> ', $txt[525], ' ', $post['poster']['link'], ' (', $post['board']['link'], ')</td>
    <td class="middletext" align="right" valign="top" nowrap="nowrap">', $post['time'], '</td>
    </tr>';
    echo '
    </table>';
    }
Nothing is true, everything is permitted.

60CHEVY

bilgi için teşekkürler,bu bilgiyi webmaster'ımıza aktaracağım çünkü biz sadece yönetici pozisyonundayız forumumuzda,teknik yeterliliğimiz maalesef ki yok.Yalnız bizim temamız Dilber MC.Yapılacak işlem değişiyormu acaba?

Badboy

#3
Evet sadece BoardIndex.template.php dosyanız farklı. Onun içinde aşağıdaki işlemi yapacaksınız.

Code (ŞUNU BULUN) Select
// Show lots of posts.
elseif (!empty($context['latest_posts']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%">';

/* Each post in latest_posts has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_posts'] as $post)
echo '
<tr>
<td class="windowbg" valign="middle" width="40%" style="padding-left: 10px; font-size:85%">', $post['link'], '</td>
<td class="windowbg" valign="middle" width="15%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['poster']['link'], '</td>
<td class="windowbg" valign="middle" width="25%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['board']['link'], '</td>
<td class="windowbg" valign="middle" width="20%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['time'], '</td>

</tr>';
echo '
</table>';
}


Code (ŞUNUNLA DEĞİŞTİRİN) Select
// Show lots of topics.
elseif (!empty($context['latest_topics']))
{
echo '
<table cellpadding="0" cellspacing="0" width="100%">';

/* Each post in latest_topics has:
board (with an id, name, and link.), topic (the topic's id.), poster (with id, name, and link.),
subject, short_subject (shortened with...), time, link, and href. */
foreach ($context['latest_topics'] as $post)
echo '
<tr>
<td class="windowbg" valign="middle" width="40%" style="padding-left: 10px; font-size:85%">', $post['link'], '</td>
<td class="windowbg" valign="middle" width="15%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['poster']['link'], '</td>
<td class="windowbg" valign="middle" width="25%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['board']['link'], '</td>
<td class="windowbg" valign="middle" width="20%" style="padding-left: 10px; font-size:85%" nowrap="nowrap">', $post['time'], '</td>

</tr>';
echo '
</table>';
}
Nothing is true, everything is permitted.

Minare

Soruyu yanlıs da anlamıs olabilirim.

Ama bunun için sadece


sources klasöründe recent.php dosyasındaki

AND t.ID_TOPIC = m.ID_TOPIC

kodunu

AND m.ID_MSG = t.ID_LAST_MSG

ile değiştirmek yeterli değil mi ?

Selametle


Badboy

Minare ben fonksiyonları ayırmak için biraz daha uzun bir yol seçtim. Dediğiniz gibi de olur ancak konu başlıkları hatalı olacaktır.

Bu yüzden aşağıdaki fonksiyonda değişmesi gereken kısımları belirteyim.

Code (DEĞİŞİKLİK YAPACAĞIMIZ FONKSİYON) Select
function getLastPosts($showlatestcount)
{
global $scripturl, $txt, $db_prefix, $user_info, $modSettings, $func;

// Find all the posts.  Newer ones will have higher IDs.  (assuming the last 20 * number are accessable...)
// !!!SLOW This query is now slow, NEEDS to be fixed.  Maybe break into two?
$request = db_query("
SELECT
m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,
IFNULL(mem.realName, m.posterName) AS posterName, t.ID_BOARD, b.name AS bName,
LEFT(m.body, 384) AS body, m.smileysEnabled
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)
WHERE m.ID_MSG >= " . max(0, $modSettings['maxMsgID'] - 20 * $showlatestcount) . "
AND t.ID_TOPIC = m.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? "
AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG DESC
LIMIT $showlatestcount", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
// Censor the subject and post for the preview ;).
censorText($row['subject']);
censorText($row['body']);

$row['body'] = strip_tags(strtr(parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']), array('<br />' => '')));
if ($func['strlen']($row['body']) > 128)
$row['body'] = $func['substr']($row['body'], 0, 128) . '...';

// Build the array.
$posts[] = array(
'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>'
),
'topic' => $row['ID_TOPIC'],
'poster' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'href' => empty($row['ID_MEMBER']) ? '' : $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>'
),
'subject' => $row['subject'],
'short_subject' => shorten_subject($row['subject'], 24),
'preview' => $row['body'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'raw_timestamp' => $row['posterTime'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . ';topicseen#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>'
);
}
mysql_free_result($request);

return $posts;
}


Code (ŞUNU BULUYORUZ) Select
m.posterTime, m.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,

Code (ŞUNUNLA DEĞİŞTİRİYORUZ) Select
m.posterTime, ms.subject, m.ID_TOPIC, m.ID_MEMBER, m.ID_MSG,

Code (ŞUNU BULUYORUZ) Select
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)

Code (ŞUNUNLA DEĞİŞTİRİYORUZ) Select
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b, {$db_prefix}messages AS ms)

Code (ŞUNU BULUYORUZ) Select
AND t.ID_TOPIC = m.ID_TOPIC

Code (ŞUNUNLA DEĞİŞTİRİYORUZ) Select
AND t.ID_LAST_MSG = m.ID_MSG

Code (ŞUNU BULUYORUZ) Select
AND $user_info[query_see_board]

Code (ALTINA EKLİYORUZ) Select
AND ms.ID_MSG = t.ID_FIRST_MSG
Nothing is true, everything is permitted.

Minare


[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal


Advertisement: