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: 1
  • Guests: 565
  • Total: 566
  • @rjen

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 2 Guests are viewing this topic.

JPDeni


Puchu

I dont know, we probably dont, but I also tried it without the _REVERSE, and it did the same thing...

And yes Im putting it into a php block...

Puchu

okay I tried some of the other codes, I got something to show up, don't like the view of them...

But the problem is now I must type in an estimated, 50 boards or so to exclude them...  and then add a few more here and there...

JPDeni

QuoteBut the problem is now I must type in an estimated, 50 boards or so to exclude them.
That's the point of the REVERSE function. Follow the instructions in the other topic to create that function and you will be able to show only the boards that you want, instead of showing everything except the ones you don't want.

Puchu

Quote from: JPDeni on October 20, 2006, 10:26:20 PM
QuoteBut the problem is now I must type in an estimated, 50 boards or so to exclude them.
That's the point of the REVERSE function. Follow the instructions in the other topic to create that function and you will be able to show only the boards that you want, instead of showing everything except the ones you don't want.

You mean in this thread a few pages back???

If thats it I must edit a file... but I need to get the person who is hosting the site (individual not company) to get the ftp working again for the admins... or have him do it himself which will probably never happen lol

Is there a way to show just how the recent topics built in the tp is and array them???  Because most others are made different... and Ill do that instead so I dont have to bother anybody...

JPDeni

Yes, that's the one. You can put functions into a php article or block.

I'll come back to this in a bit and give you the code you need to use.

JPDeni

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

$num_recent = 10;
$include_boards = array(5,6,17);

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

// Print out the results

foreach($result as $my){
  echo "$bullet";
  echo '<span class="smalltext">'.$my['link'];
  // is this topic new? (assume they are logged in)
  if (!$my['new'] && $context['user']['is_logged'])
  echo '
    <a href="', $scripturl, '?topic=', $my['topic'], '.from', $my['newtime'], '#new">
    <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" border="0" /></a>';
  echo '</span>';
  echo '<br>';
}

Puchu

I put that in and it cuts off the tp on that side and only shows the title bar...  none of the blocks below where it would go shows...

EDIT:
unless that is what needs modified in the file... which I can't get to that file if that is the case :-/


$result=ssi_recentTopics(10,array(5,6,7,8,9,10,13,15,16,17,18,19,22,23,24,25,226,27,28,29,30,31,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,105,106,107,108,109),'array');
echo'<right>';
echo '<ul style="padding-left: 15px;">';
foreach($result as $my){
echo '<Li>'.$my['link'].'</Li>';
if(!$my['new'])
echo '<a href="'.$my['href'].'"><img border="0" src="'.$settings['images_url'].'/'.$context['user']['language'].'/new.gif" alt="new" /></a> ';
}
echo '</UL>';
echo'</center>';
echo '<span class="smalltext"></span>';


Thats the code I have to use if I type in all the boards to be excluded...  only problem with this I really don't like how it looks...  I want the date, time, title, and new to show...


basically default view in TP with all my baords I have listed exlcuded is what I want =P

EDIT 2:
I got the size smaller...  moved the span class... now would just like the timestamp... also noticed that the background is a different color than all the other blocks... dont understand that...

JPDeni

I don't understand either what you did or what you got when you used the code I posted.

The code I gave you can go into a php block or a php article. It's all self-contained so you don't have to edit any files. I guess I didn't explain that you need to enter the board numbers that you want to use, separated by commas in the $include_boards variable. If you did that, can I see the result that you got? Either give me a URL where I can see it or take a screenshot and attach it to your post.

If you want to mess around with listing all the boards to exclude, you can, but it really would be easier to get the code to work so you can just list the boards to include.

Puchu

Here is a picture of what it does with your code in a php block...

With the other code its background changed colors and its attached as well...  the rest of the blocks are black possibly transparent...


This website is proudly hosted on Crocweb Cloud Website Hosting.