Dylert Posted November 17, 2013 Share Posted November 17, 2013 Hello! I'm new here and this is my first post! Hello!I have a block code to my forum. The block shows a table with recent topics. The problem is that it shows only name of topic, poster and date. I would like to add topic starter and board name (and maybe (views/read). Can anyone help me with this? $num_recent = 25; // HOW MANY RECENT TOPICS TO OUTPUT? $include_boards = null; // IF ALL BOARDS null | IF SOME BOARDS array( ID1, ID2, ID3) // code, code, code and some more code bahhh! global $smcFunc, $scripturl, $context, $settings, $db_prefix, $user_info; if (is_array($include_boards) || (int) $include_boards === $include_boards) { $include_boards = is_array($include_boards) ? $include_boards : array($include_boards); } elseif ($include_boards != null) { $output_method = $include_boards; $include_boards = array(); } $topics_result = $smcFunc['db_query']('', ' SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, b.id_board, t.id_last_msg, u.avatar, g.online_color, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : ' IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read, IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ' FROM {db_prefix}topics AS t INNER JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board) INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg) LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member) LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)' . (!$user_info['is_guest'] ? ' LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member}) LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . ' WHERE m.approved=1' . (empty($include_boards) ? '' : ' AND b.id_board IN ({array_int:include_boards})') . ' ORDER BY t.id_last_msg DESC LIMIT ' . $num_recent, array( 'current_member' => $user_info['id'], 'include_boards' => empty($include_boards) ? '' : $include_boards, ) ); $topics = array(); while ($row_topics = $smcFunc['db_fetch_assoc']($topics_result)) { $topics[] = array( 'topic' => $row_topics['id_topic'], 'poster' => '<a style="color: ' . $row_topics['online_color'] . ';" href="' . $scripturl . '?action=profile;u=' . $row_topics['id_member_updated'] . '">' . $row_topics['poster_name'] . '</a>', 'link' => '<a title="In ' . $row_topics['name'] .'" href="' . $scripturl . '?topic=' . $row_topics['id_topic'] . '.msg' . $row_topics['id_last_msg'] . ';topicseen#new">' . $row_topics['subject'] . '</a>', 'href' => $scripturl . '?topic=' . $row_topics['id_topic'] . '.msg' . $row_topics['id_last_msg'] . ';topicseen#new', 'time' => timeformat($row_topics['poster_time']), 'new' => !empty($row_topics['is_read']) ); } $smcFunc['db_free_result']($topics_result); echo ' <div class="tabsmenucontent" style="padding: 2px"> <table border="0" width="100%" cellspacing="1" cellpadding="2" class="bordercolor"> <tr class="titlebg"> <td valign="middle">Topic</td> <td valign="middle">Poster</td> <td valign="middle">Time</td> <td valign="middle"></td> </tr>'; foreach ($topics as $topic) { echo ' <tr> <td class="windowbg" valign="middle">', $topic['link']; // new log! What a headache! if (!$topic['new'] && $context['user']['is_logged']) echo ' <a href="', $scripturl, '?topic=', $topic['topic'], '.from', $topic['time'], '#new"><img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="new" border="0" /></a>'; echo ' </td> <td class="windowbg2" valign="middle">', $topic['poster'], '</td> <td class="windowbg2" valign="middle">', $topic['time'], '</td> <td class="windowbg2" valign="middle">'; if ($settings['images_url'] != $settings['theme_url'] . '/images' || file_exists($settings['theme_dir'] . '/images/icons/last_post.gif')) echo ' <a href="', $topic['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="Last Post" title="Last Post" border="0" style="float: right;" /></a>'; } echo ' </td> </tr> </table> </div>'; Quote Link to comment Share on other sites More sharing options...
Flail Posted November 18, 2013 Share Posted November 18, 2013 what does your topic starter / board name meant? any info stored in db regarding this ? number of views per click or per machine ? Quote Link to comment Share on other sites More sharing options...
Dylert Posted November 18, 2013 Author Share Posted November 18, 2013 The code makes a table in a block with recent topics from my forum. Now there are thre columns: Name of topc, poster and date. I want to make five columns: Name of topic, board-name, topic-starter, poster and date. By views/posts I mean how many has visited the the post and how many answers. This is not very important. All info is stored in the database. It is a SMF forum (Simple Machines Forum). Any suggestions on how to edit the code? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.