Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: Pipke - helmikuu 21, 2014, 08:53:02 AP

Otsikko: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: Pipke - helmikuu 21, 2014, 08:53:02 AP
on this page--> site url../index.php?action=recent

on file Sources/Recent.php and Recent.Template.php i think?
i want to display icon of the posts that i have posted in then.

it has to do with this:
if (!empty($modSettings['enableParticipation']) && !$user_info['is_guest'] && !empty($topic_ids))
{
$result = $smcFunc['db_query']('', '
SELECT id_topic
FROM {db_prefix}messages
WHERE id_topic IN ({array_int:topic_list})
AND id_member = {int:current_member}
GROUP BY id_topic
LIMIT ' . count($topic_ids),
array(
'current_member' => $user_info['id'],
'topic_list' => $topic_ids,
)
);
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$context['topics'][$row['id_topic']]['is_posted_in'] = true;
$context['topics'][$row['id_topic']]['class'] = 'my_' . $context['topics'][$row['id_topic']]['class'];
}
$smcFunc['db_free_result']($result);
}


but dont know how to add it to the script.

function RecentPosts()

// Get all the most recent posts.
$request = $smcFunc['db_query']('', '
SELECT
m.id_msg, m.subject, m.smileys_enabled, m.poster_time, m.body, m.id_topic, t.id_board, b.id_cat,
b.name AS bname, c.name AS cname, t.num_replies, m.id_member, m2.id_member AS id_first_member,
IFNULL(mem2.real_name, m2.poster_name) AS first_poster_name, t.id_first_msg,
IFNULL(mem.real_name, m.poster_name) AS poster_name, t.id_last_msg
FROM {db_prefix}messages AS m
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}boards AS b ON (b.id_board = t.id_board)
INNER JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)
INNER JOIN {db_prefix}messages AS m2 ON (m2.id_msg = t.id_first_msg)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
LEFT JOIN {db_prefix}members AS mem2 ON (mem2.id_member = m2.id_member)
WHERE m.id_msg IN ({array_int:message_list})
ORDER BY m.id_msg DESC
LIMIT ' . count($messages),
array(
'message_list' => $messages,
)


thx for anyhelp.
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: margarett - helmikuu 21, 2014, 09:54:35 AP
Those icons aren't really used in Recent...

That icon shows up when there is a topics listing (MessageIndex, Recent, Unread). In Recent, the listing is by post. So that query doesn't really affect it.

You should be able to perform something along those lines nevertheless, let me take a peek here.
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: margarett - helmikuu 21, 2014, 10:17:51 AP
Would something like this serve you?

(https://www.simplemachines.org/community/index.php?action=dlattach;topic=518876.0;attach=229242;image)
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: Pipke - helmikuu 21, 2014, 10:40:49 AP
yes, that is '' i think' what i'm looking for, like when you(i) have posted or replied in a certain topic, it shows the icon.
thx for the help
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: margarett - helmikuu 21, 2014, 11:05:54 AP
It's really an easy trick.

Sources/Recent.php
Find:
'delete_possible' => ($row['id_first_msg'] != $row['id_msg'] || $row['id_last_msg'] == $row['id_msg']) && (empty($modSettings['edit_disable_time']) || $row['poster_time'] + $modSettings['edit_disable_time'] * 60 >= time()),
Add after:
'is_own_post' => $user_info['is_guest'] ? '' : $row['id_member'] == $user_info['id'],

Themes/default/Recent.template.php
Find:
<h5>', $post['board']['link'], ' / ', $post['link'], '</h5>
Replace with:
<h5>',!empty($post['is_own_post']) ? '<img src="' . $settings['images_url'] . '/topic/my_normal_post.gif" alt="" />' : '' ,'', $post['board']['link'], ' / ', $post['link'], '</h5>
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: Pipke - helmikuu 21, 2014, 11:16:13 AP
wow, really fast, but one question, works this only for the first post what i have started/made(topic start), or also when i have replied on a topic from another member?
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: margarett - helmikuu 21, 2014, 11:37:52 AP
It will mark any post that you made, be it the first post of the topic or not, be it your topic or or
Otsikko: Re: how to get 'info' if you have posted in the topic/post on recent posts page
Kirjoitti: Pipke - helmikuu 21, 2014, 11:39:47 AP
Lainaus käyttäjältä: Pipke - helmikuu 21, 2014, 11:16:13 AP
wow, really fast, but one question, works this only for the first post what i have started/made(topic start), or also when i have replied on a topic from another member?

yes it does i think, checked the array quick, working better on script later tonight, thx again for the great help.

topic marked as solved.