Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: [SiNaN] in Juni 04, 2008, 11:45:57 VORMITTAG

Titel: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 11:45:57 VORMITTAG
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 '
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juni 04, 2008, 12:15:14 NACHMITTAGS
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?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 12:20:53 NACHMITTAGS
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>

Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jossanaijr in Juni 04, 2008, 12:24:44 NACHMITTAGS
Wow!  I had already asked for this sometime ago...
Please submit it to MOD site.
Thanks!
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 12:26:23 NACHMITTAGS
This is not that complex to be a mod. But I can think of adding a view count and view time for members. Maybe.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jossanaijr in Juni 04, 2008, 12:27:37 NACHMITTAGS
SiNan - > Sadrazam!
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jossanaijr in Juni 04, 2008, 12:28:54 NACHMITTAGS
Question: Who can see this list?  All that can read the post?  And if member list is not public?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juni 04, 2008, 12:29:31 NACHMITTAGS
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.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 12:38:12 NACHMITTAGS
Zitat von: jossanaijr in Juni 04, 2008, 12:27:37 NACHMITTAGS
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 '
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 12:41:31 NACHMITTAGS
Zitat von: Eliana Tamerin in Juni 04, 2008, 12:29:31 NACHMITTAGS
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');.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juni 04, 2008, 12:55:05 NACHMITTAGS
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>' : '', '
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 12:56:41 NACHMITTAGS
Okay, mod will include a permission for viewing it. Any other ideas?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juni 04, 2008, 01:02:53 NACHMITTAGS
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
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 04, 2008, 01:03:58 NACHMITTAGS
Exactly what I thought Eliana, thanks. ;)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jossanaijr in Juni 04, 2008, 01:08:20 NACHMITTAGS
Wow!
Installed and working perfectly!
Thanks again!
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jossanaijr in Juni 04, 2008, 01:12:38 NACHMITTAGS
BTW, is it ordered alphabetically or by order?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 05, 2008, 02:11:23 VORMITTAG
Zitat von: jossanaijr in Juni 04, 2008, 01:12:38 NACHMITTAGS
BTW, is it ordered alphabetically or by order?

By order I guess.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: H in Juni 05, 2008, 12:37:54 NACHMITTAGS
Topic moved to Tips and Tricks :D
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 05, 2008, 12:38:18 NACHMITTAGS
Zitat von: H in Juni 05, 2008, 12:37:54 NACHMITTAGS
Topic moved to Tips and Tricks :D

Thanks Huw. :)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: jdizine in Juni 12, 2008, 05:44:22 VORMITTAG
@[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.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juni 12, 2008, 09:06:57 VORMITTAG
He has not yet made the mod.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Nibogo in Juni 16, 2008, 08:29:39 NACHMITTAGS
Sinan awesome job!!!

thanks :)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 19, 2008, 07:06:46 VORMITTAG
Thanks, hope I'll do it soon. ;)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Nibogo in Juni 21, 2008, 09:12:33 VORMITTAG
Zitat von: [SiNaN] in Juni 19, 2008, 07:06:46 VORMITTAG
Thanks, hope I'll do it soon. ;)

How i can do to make of topic author can see the log???
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 21, 2008, 09:44:21 VORMITTAG
Here is your codes:

Display.php

Find:

fatal_lang_error('smf232', false);

Replace:

fatal_lang_error('smf232', false);

$request = db_query("
SELECT ID_MEMBER_STARTED
FROM {$db_prefix}topics
WHERE ID_TOPIC = $topic
LIMIT 1", __FILE__, __LINE__);
list ($starter) = mysql_fetch_row($request);
mysql_free_result($request);

if($starter = $ID_MEMBER || allowedTo('moderate_forum'))
$context['can_view_who_viewed'] = true;
else
$context['can_view_who_viewed'] = false;

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


And in the DisplayLog() function, you should remove:

isAllowedTo('moderate_forum');

Also you can use $context['can_view_who_viewed'] in the template file to show the button only for the starter.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Kalina in Juni 28, 2008, 07:52:40 NACHMITTAGS
I think I am doing something wrong, how can I make it so any member can view the list? I want anyone except guests to be able to view it. Thanks. :)

I put this in MessageIndex.template.php
                            ', !$context['user']['is_guest'] ? '<a href="' . $scripturl . '?topic='. $topic['id'] . '.0;sa=log">' . $topic['views'] . '</a>' : $topic['views'], '

But it says to regular members: "You are not allowed to moderate this forum."

I thought the code above would make it so anyone but guests can see.

Edit: Ok, so I just had to remove "   isAllowedTo('moderate_forum');" from my Display.php
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juni 29, 2008, 08:59:35 VORMITTAG
Glad that you've managed to do it. You can deny guests by just adding this code instead of the one you removed:

is_not_guest();
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Sarge in Juli 05, 2008, 06:52:43 VORMITTAG
That's cool, [SiNaN] :)

Can you package it as a mod?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juli 05, 2008, 06:54:36 VORMITTAG
It's quite ready. Just need to check permissions in the Display.template.php.

The mod will include:

- How many times member viewed
- Time of members' last view
- Sorting of members by username, position, last view time, times viewed
- Showing 20 members per page
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Sarge in Juli 05, 2008, 06:56:55 VORMITTAG
Zitat von: [SiNaN] in Juli 05, 2008, 06:54:36 VORMITTAG
- Showing 20 members per page

Can you make the number configurable?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juli 05, 2008, 07:02:23 VORMITTAG
I just do not want to add something to the ModSettings. I don't think it is that much important. If you personally want to change the number, just you need to change the number 20 to what you want in Display.php.

But if you say, we need, they I can add. Do we really need?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Sarge in Juli 05, 2008, 07:07:18 VORMITTAG
Zitat von: [SiNaN] in Juli 05, 2008, 07:02:23 VORMITTAG
But if you say, we need, they I can add. Do we really need?

It was just a suggestion (I personally don't need it).

It's totally up to you. :)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Kalina in Juli 05, 2008, 03:44:44 NACHMITTAGS
Zitat von: [SiNaN] in Juli 05, 2008, 06:54:36 VORMITTAG
It's quite ready. Just need to check permissions in the Display.template.php.

The mod will include:

- How many times member viewed
- Time of members' last view
- Sorting of members by username, position, last view time, times viewed
- Showing 20 members per page

That's awesome, looking forward to it. Thank you. :)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Nibogo in Juli 05, 2008, 09:53:38 NACHMITTAGS
Zitat von: [SiNaN] in Juli 05, 2008, 06:54:36 VORMITTAG
It's quite ready. Just need to check permissions in the Display.template.php.

The mod will include:

- How many times member viewed
- Time of members' last view
- Sorting of members by username, position, last view time, times viewed
- Showing 20 members per page

Awesome ideas!!
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juli 06, 2008, 03:08:44 VORMITTAG
Zitat von: Sarge in Juli 05, 2008, 07:07:18 VORMITTAG
It was just a suggestion (I personally don't need it).

It's totally up to you. :)

Sorry Sarge, didn't thought of that you can code a better one if you will need. :)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juli 06, 2008, 10:05:22 NACHMITTAGS
If you make sure the number is easy to find in the code, it'll be easy for anyone who wants to change that to do so.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: edi67 in Juli 07, 2008, 01:46:36 NACHMITTAGS
nice work
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: avf in Juli 27, 2008, 08:10:35 VORMITTAG
Zitat von: [SiNaN] in Juli 05, 2008, 06:54:36 VORMITTAG
It's quite ready. Just need to check permissions in the Display.template.php.

The mod will include:

- How many times member viewed
- Time of members' last view
- Sorting of members by username, position, last view time, times viewed
- Showing 20 members per page

very nice thank you
waiting for the updated version
avf
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: [SiNaN] in Juli 27, 2008, 08:15:52 VORMITTAG
Mod is released. See it here:

http://custom.simplemachines.org/mods/index.php?mod=1300
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Deprecated in Juli 29, 2008, 12:59:47 VORMITTAG
Zitat von: [SiNaN] in Juni 04, 2008, 12:20:53 NACHMITTAGS
Nothing is impossible. :P

That's the essence of why we all like writing software. :)

Other mortals walk around the mountain, walk over the mountain. We programmers lift up the mountain and walk under it. ;)
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: bros in Juli 30, 2008, 03:00:44 NACHMITTAGS
Zitat von: [SiNaN] in Juli 27, 2008, 08:15:52 VORMITTAG
Mod is released. See it here:

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

Would that work with SMF 2?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in Juli 30, 2008, 03:12:40 NACHMITTAGS
Compatible With:     1.1.5

Hmm, let's see. No.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Low in August 05, 2008, 09:50:39 NACHMITTAGS
This mod has totally messed my forum. I installed CORRECTLY. As soon as I did I have a load of text/ Jargon above my header when logged in. I uninstalled and deleted but the jargon is still there. :(
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in August 05, 2008, 09:56:14 NACHMITTAGS
There is a mod for this now. Why don't you try that?
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Low in August 05, 2008, 09:59:51 NACHMITTAGS
I did! what other way is there?

Either way I don't even want it now I'd rather get my forum back to normal health.

Any help would be much appreciated as I'm sure this has happened to others.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Eliana Tamerin in August 05, 2008, 10:02:14 NACHMITTAGS
Go into your Modifications.english.php and move the ?> to the end of the file.
Titel: Re: [TIP/TRICK] Who Viewed The Topic
Beitrag von: Paul123 in April 26, 2012, 11:11:53 NACHMITTAGS
Hello,

This topic has been a while.  I'm trying to modify my forum and it may relate to this mod; perhaps I can get some help from here.

Is it possible to modify my forum so that everytime users view some special topics (I got about 5 special topics), their nicks will turn to different colors, and then if they got off those special topcis, their nicks' color will be back to normal.

Any help will be appreciated.  I'm trying to work on this, but not much clue so far.  Please help.  I'm willing to pay to get my forum work. 

Thanks very much.

I'm using smf 1.1.16