News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

[gelöst]ssi - letzten 5 Topics, aus bestimmten Foren

Started by Badelehrling, August 18, 2006, 01:19:25 PM

Previous topic - Next topic

Badelehrling

Hallo,

Kann mir jemand sagen, wie ich so wie mit dieser Funktion "<?php ssi_recentTopics(); ?>", die letzten 5 Beiträge, aus bestimmten Boards anzeigen lassen kann??
Mit der Forensuche habe ich zwar einiges gefunden, aber immer auf Englisch, und damit komme ich nicht ausreichend zurecht :'(. Ich glaube, ich muss da irgendwo Board-Ids, ausklammern... allerdings weiss ich nicht wo und wie. Board IDs herausbekommen, schaffe ich aber noch...

Wäre spitze, wenn mir jemand helfen könnte.

Beste Grüsse,
Badelehrling

Edit/ ganz vergessen: Habe SMF 1.0.7!


noex

Sieh dir mal die SSI.php an, dort stehen die Parameter die du der Funktion übergeben musst.

lg
noex
"Jetzt, wo ich weiß wie es geht, versteh ich auch die Gebrauchsanleitung"

Badelehrling

Joa, und genau dafür bin ich zu dumm :(

Ich glaube, ich muss in diesen Zeilen was ändern:
// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = array(), $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings;

// 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 logTime' : '
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) >= GREATEST(m.posterTime, m.modifiedTime) AS isRead,
IFNULL(lt.logTime, IFNULL(lmr.logTime, 0)) AS logTime') . "
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 m.ID_MSG >= " . ($modSettings['maxMsgID'] - 8 * $num_recent) . "
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 m.ID_MSG DESC
LIMIT $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
// Censor the subject.
censorText($row['subject']);

// 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' => strlen(un_htmlspecialchars($row['subject'])) > 25 ? htmlspecialchars(substr(un_htmlspecialchars($row['subject']), 0, 22) . '...') : $row['subject'],
'time' => timeformat($row['posterTime']),
'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'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
'new' => !empty($row['isRead']),
'newtime' => $row['logTime']
);
}
mysql_free_result($request);

// Just return it.
if ($output_method != 'echo' || empty($posts))
return $posts;

echo '
<table border="0" class="ssi_table">';
foreach ($posts as $post)
echo '
<tr>
<td align="right" valign="top" nowrap="nowrap">
[', $post['board']['link'], ']
</td>
<td valign="top">
<a href="', $post['href'], '">', $post['subject'], '</a>
', $txt[525], ' ', $post['poster']['link'], '
', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.from' . $post['newtime'] . ';topicseen#new"><img src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" alt="' . $txt[302] . '" border="0" /></a>', '
</td>
<td align="right" nowrap="nowrap">
', $post['time'], '
</td>
</tr>';
echo '
</table>';
}


Stimmt das? Und wo kann ich eingeben, aus welchen Boards die 5(!) neuesten Themen genommen werden dürfen, bzw. aus welchen nicht?

Schonmal danke :)
Greetz,
Badelehrling

noex

Ne, nichts in der SSI.ph ändern.

Du rufst die Funktion zB. so auf:

ssi_recentTopics(5, array(1,2,4,5,6));

Ich gehe in meinen Beispiel davon aus das es 7 Boards gibt. Soweit so gut. Du willst jetzt aber nur die neuesten 5 Beiträge aus den Board 3 und 7. Dies machst du wie oben beschrieben. Also die erste Zahl (die 5) ist die Anzahl der Beiträge. Die Boards die in diesem array() stehen, werden ausgeschlossen. In meinen Beispiel also 1 2 4 5 und 6.

Hoffe ich konnte dir damit etwas weiterhelfen.

lg
noex

"Jetzt, wo ich weiß wie es geht, versteh ich auch die Gebrauchsanleitung"

Badelehrling

Vielen Dank!

Klappt alles genau so wie ich es mir vorgestellt habe ;)

Thx for the n1 Support :)

Advertisement: