News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[TIP/TRICK] Who Viewed The Topic

Started by [SiNaN], June 04, 2008, 11:45:57 AM

Previous topic - Next topic

[SiNaN]

Mod is out:

http://custom.simplemachines.org/mods/index.php?mod=1300

This trick will allow you to view the users that viewed the topic.


../Sources/Display.php

Find:

fatal_lang_error('smf232', false);

Replace:

fatal_lang_error('smf232', false);

if(!empty($_REQUEST['sa']) && $_REQUEST['sa'] == 'log') {
DisplayLog();
}


Find:

?>

Replace:

function DisplayLog()
{
global $context, $scripturl, $db_prefix, $topic;

isAllowedTo('moderate_forum');

$request = db_query("
SELECT
lt.ID_MEMBER, lt.ID_TOPIC, mem.realName
FROM {$db_prefix}log_topics AS lt
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = lt.ID_MEMBER)
WHERE ID_TOPIC = $topic", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
// Build the array.
$context['logs'][] = array(
'member' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['realName'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['realName'] . '</a>',
'href' => $scripturl . '?action=profile;u=' . $row['ID_MEMBER'],
),
);
}
mysql_free_result($request);

$context['sub_template'] = 'displaylog';
}

?>


../Themes/default/Display.template.php

Find:

?>

Replace:

function template_displaylog()
{
global $context, $settings, $options, $txt, $scripturl, $modSettings;

echo '
<table border="0" cellpadding="0" cellspacing="0" style="padding-top: 1ex;" align="center">
<tr class="titlebg">
<td>Who Viewed The Topic</td>
</tr>';

foreach($context['logs'] as $log) {
echo '
<tr class="windowbg">
<td>', $log['member']['link'], '</td>
</tr>';
}

echo '
</table>';
}

?>


Find:

<div class="nav" style="margin-bottom: 2px;"> ', $context['previous_next'], '</div>

Replace:

<div class="nav" style="margin-bottom: 2px;"> ', $context['previous_next'], '</div>';
if($context['can_moderate_forum'])
echo '
<a href="' . $scripturl . '?topic='. $context['current_topic'] . '.0;sa=log">View Topic Log</a>';
echo '
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

SiNaN, that's seriously amazing! Awesome job!

I'm using this and it works wonderfully.

I've seen this kind of thing on other forum software, and the one other place I've seen it is on the Message Index, under the Views column. The number of views would be a link to the View Topic Log or whatever they called it. Do you think that's possible?
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Nothing is impossible. :P

I hope I understand your question correctly.

../Themes/default/MessageIndex.template.php

Find:

', $topic['views'], '

Replace:

<a href="' . $scripturl . '?topic='. $topic['id'] . '.0;sa=log">', $topic['views'], '</a>

Former SMF Core Developer | My Mods | SimplePortal

jossanaijr

Wow!  I had already asked for this sometime ago...
Please submit it to MOD site.
Thanks!

[SiNaN]

This is not that complex to be a mod. But I can think of adding a view count and view time for members. Maybe.
Former SMF Core Developer | My Mods | SimplePortal

jossanaijr


jossanaijr

Question: Who can see this list?  All that can read the post?  And if member list is not public?

Eliana Tamerin

Yep, you understood perfectly. ;)

Hehe, I should have thought of that. No matter. Works beautifully.

Thanks again!

BTW, View Count and time would be an awesome feature.
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Quote from: jossanaijr on June 04, 2008, 12:27:37 PM
SiNan - > Sadrazam!

Yes. :)

What about just the users who has the moderate forum permission?

Change the code like this:

Find:

<div class="nav" style="margin-bottom: 2px;"> ', $context['previous_next'], '</div>

Replace:

<div class="nav" style="margin-bottom: 2px;"> ', $context['previous_next'], '</div>';
if($context['can_moderate_forum'])
echo '
<a href="' . $scripturl . '?topic='. $context['current_topic'] . '.0;sa=log">View Topic Log</a>';
echo '
Former SMF Core Developer | My Mods | SimplePortal

[SiNaN]

#9
Quote from: Eliana Tamerin on June 04, 2008, 12:29:31 PM
Yep, you understood perfectly. ;)

Hehe, I should have thought of that. No matter. Works beautifully.

Thanks again!

BTW, View Count and time would be an awesome feature.

And this is for you Eliana:

MessageIndex.template.php

Find:

', $topic['views'], '

Replace:

', $context['can_moderate_forum'] ? '<a href="' . $scripturl . '?topic='. $topic['id'] . '.0;sa=log">' . $topic['views'] . '</a>' : $topic['views'], '

Also you can use !$context['user']['is_guest'] instead of $context['can_moderate_forum'] if you want it to display it just for users.

I'll make a mod with view count and time after my finals.

Made it more secure, added isAllowedTo('moderate_forum');.
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

Awesome. And I've used this context on the Display.template.php file instead.

', !$context['user']['is_guest'] ? '<a href="' . $scripturl . '?topic='. $context['current_topic'] . '.0;sa=log" class="middletext"><b>View Topic Log</b></a>' : '', '
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Okay, mod will include a permission for viewing it. Any other ideas?
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

Maybe a little table of information.








Member Name 1        Last Viewed Time       (Views #)
Member Name 2Last Viewed Time(Views #)
Member Name 3Last Viewed Time(Views #)
Member Name 4Last Viewed Time(Views #)
Member Name 5Last Viewed Time(Views #)
GuestsLast Viewed Time(Views #)
Total Views
Do NOT PM me for support.

SimplePortal 2.3.6 is OUT!
SimplePortal Project Manager
Download | Docs
SimplePortal: Power of Simplicity!

[SiNaN]

Exactly what I thought Eliana, thanks. ;)
Former SMF Core Developer | My Mods | SimplePortal

jossanaijr

Wow!
Installed and working perfectly!
Thanks again!

jossanaijr

BTW, is it ordered alphabetically or by order?

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

H

-H
Former Support Team Lead
                              I recommend:
Namecheap (domains)
Fastmail (e-mail)
Linode (VPS)
                             

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

jdizine

@[SiNaN]  I looked at your mods I never noticed they have that down there at the bottom!
Anyway, I don't know much but I have a couple of your mods installed and they work wonderfully!
I trust your work!
Have you made that mod yet? "Who Viewed The Topic"
I looked but I didn't see it.



Advertisement: