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,913
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 448
  • Total: 448

Re: "recent topics" in SMF style [Include Boards]

Started by insanemustang, January 07, 2009, 08:38:55 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ZarPrime

insanemustang,

I may still be a little confused as to what you want to do, but if that other one didn't do it, you might want to take a look at this code that JPDeni posted a couple of years ago.  I don't think it gives you everything that is in a normal recent posts block using the SSI function, but it will give you the most recent topics from a particular board or boards that you specify near the top of the code.  The link is here ---> http://www.tinyportal.net/index.php/topic,1234.msg81842.html#msg81842

If that doesn't do it, you might want to post a new topic in Block Code requests and let somebody take a stab at what you're looking for.

ZarPrime

pedrox

#11
I also want very to understand this  ???


where folder I put this?

ssi_recentTopics('8', array('3','56') , 'array'):

ZarPrime

pedrox,

you don't have to put it anywhere.

ssi_recentTopics is a function that is already built into SMF.  This block only makes use of it.  The 8 specifies how many topics to show, and the other 2 numbers specify boards to exclude.

I know this is a long topic but if you want to know what the block code is all about, you would be better off to start back on page 1 of this topic and read what it's all about starting here ---> http://www.tinyportal.net/index.php/topic,596.msg4654.html#msg4654

ZarPrime

insanemustang

Ok, I used the code in that thread.  And I customized the look of it, but the "new" icon's link points straight to this "......index.php?topic=Array.from#new" and it goes to the home page, not to that thread's newest post.

G6Cad



G6Cad

Then tell us your setup, what you have done, how you done it, and what you have tried so we dont have to ask for every thing  ;)  :D

ZarPrime

insanemustang,

I have split your posts into this new topic because what you are trying to do is include boards instead of exclude boards.  This will keep people from getting confused about the original topic.

Please post your info in this topic as G6 suggested instead of the original one so that we can help you.

ZarPrime

insanemustang

#18
Thanks.

I used the include code, and was able to get it working, kind of.  Let me show you my code first.

global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER;
global $user_info, $modSettings, $func;

$num_recent = 10;
$include_boards = array(5);

$bullet = '<img src="'.$settings['images_url'].'/TPdivider.gif" alt="" border="0" style="margin:0 2px 0 0;" />';

  $include_boards = empty($include_boards) ? array() : $include_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, t.numReplies, 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($include_boards) ? '' : "
AND b.ID_BOARD IN (" . implode(', ', $include_boards) . ")") . "
" . ((!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 $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.
$result[] = 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' => array(
'id' => $row['ID_TOPIC'],
'views' => $row['numViews'],
'replies' => $row['numReplies'],
),
                                                '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);

// Print out the results
  echo '<center><img src="http://www.bamanation.net/images/footballnews.png"></center>';
  echo '<span class="smallertext">';
foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'],' ';
  echo '(', '<span class="smalltext">'.$my['topic']['replies'],') ';
  // is this topic new? (assume they are logged in)
  if (!$my['new'] && $context['user']['is_logged'])
  echo '
    <a href="', $scripturl, '?topic=', $my['topic'], '.msg', $my['newtime'], '#new">
    <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
  echo '</span>';
  echo '<span class="largetext">','<br>';
}


And attached is a screenshot of how it looks.  Problem is that I have this code running in 2 blocks, both identical code other than the number of the board included, and the image code being different.  But the code on the right is only displaying 4 threads, not the full 10 as I have inside of the code.


ZarPrime

Well, I'm not a php Guru but it may have something to do with running 2 instances of the same code.  Perhaps JPDeni, the php Guru, will step in here for a moment and take a look at this.  She may know of some reason this is happening right off the top of her pretty head. ;)

ZarPrime

This website is proudly hosted on Crocweb Cloud Website Hosting.