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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 450
  • Total: 450

custom "Recent Topics from Board X, Y, Z only" php block

Started by iowamf, November 04, 2005, 09:47:16 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

rrasco

Quote from: rrasco on October 26, 2006, 10:03:31 PM
I modified SSI.php to have 3 additional functions, exact copies of ssi_recentTopics, only numbered ssi_recentTopics1, ssi_recentTopics2, and ssi_recentTopics3.

JPDeni

I realize that. But what are they? If they are exact copies of each other, then, yes, you will get the exact same results. I was asking to see them to see if I could figure out why you were getting the results you are getting.

rrasco

This is the one I copied.  all of these have the same exact code except this:

function ssi_recentTopics($num_recent = 8, $exclude_boards = null,

was changed to:

function ssi_recentTopics1($num_recent = 8, $exclude_boards = null,

and so on up to 3.

// Recent topic list:   [board] Subject by Poster Date
function ssi_recentTopics($num_recent = 8, $exclude_boards = null, $output_method = 'echo')
{
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
$exclude_boards = array($modSettings['recycle_board']);
else
$exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;

$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($num_recent, 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 $num_recent", __FILE__, __LINE__);
$posts = array();
while ($row = mysql_fetch_assoc($request))
{
$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) . '...';

// Censor the subject.
censorText($row['subject']);
censorText($row['body']);

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']),
'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);

// 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'] . '.msg' . $post['new_from'] . ';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>';
}

JPDeni

Okay. So how are you accessing the functions? Can you give me the code you're using?

rrasco

One per block i created.

echo '<span class="smalltext">';
$result=ssi_recentTopics1(5,array(1,29,30,53,41,43,62,63,45,46,47,48,26,52,38,39,40,42,44),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if(!$my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' <br />';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';
echo '</span>';


echo '<span class="smalltext">';
$result=ssi_recentTopics2(5,array(2,21,3,28,50,51,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,49,22,23,24,25,27,1,29,30,53,45,46,47,48,26,52),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if(!$my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' <br />';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';
echo '</span>';


echo '<span class="smalltext">';
$result=ssi_recentTopics3(5,array(2,21,3,28,50,51,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,49,22,23,24,25,27,1,29,30,53,26,52,41,43,62,63,38,39,40,42,44),'array');
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
  echo '<Li>'.$my['link'];
  if(!$my['new'])
    echo ' <a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a>';
echo ' <br />';
  echo ' ',$my['time'],'</Li>';
}
echo '</UL>';
echo '</span>';

JPDeni

So that tells you that you didn't need to create the different functions, since you get the same result with whichever function you use. It doesn't make any sense that you would get the same result with all of them, though.

Wish I could figure it out.

rrasco

i dont get it either.  but if i didnt create the new functions, then only the first block you create will contain content.  the others dont work at all.  so they have to be seperate to work.  by me defining which cats to exclude, it should show content based on that.  I did at one point have the first block show its content, then the other two showed the same wrong content.  this has got be baffled.

smartmouse

Hello, i create a new ssi_recentTopics fuction in the SSi.php file and i created a new phpbox.
It works... but i get the same result of standard Recent Topics module: there are the same topics listed. Why??

I use $result=ssi_recentTopics_NEW(10,array(9),'return');

where 10 is the # of recent topics to show, and (9) is the section ID of the forum.

Why i obtain the same result of standard Recent Topics module?


Thank you and sorry for my english.

jacortina

What is the code in this new function? If it's just a copy of the original, then it WILL NOT work on an INCLUDE basis.

Just like rrasco's code above, just calling the array an include list doesn't help. The actually query has to be changed to reference the include list and use an 'IN' clause instead of a 'NOT IN' clause.

smartmouse

Quote from: J.A.Cortina on January 16, 2007, 11:44:56 PM
What is the code in this new function? If it's just a copy of the original, then it WILL NOT work on an INCLUDE basis.

Just like rrasco's code above, just calling the array an include list doesn't help. The actually query has to be changed to reference the include list and use an 'IN' clause instead of a 'NOT IN' clause.

Yes, it is a copy of original.

Sorry due my bad english i do not understand what i have to do to make new module working...

This website is proudly hosted on Crocweb Cloud Website Hosting.