Neuigkeiten:

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

Hauptmenü
Advertisement:

[TIP/TRICK] Who Viewed The Topic

Begonnen von [SiNaN], Juni 04, 2008, 11:45:57 VORMITTAG

Vorheriges Thema - Nächstes Thema

[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]

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 '
Former SMF Core Developer | My Mods | SimplePortal

[SiNaN]

#9
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');.
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]

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.



Eliana Tamerin

Do NOT PM me for support.

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


[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal


[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

Kalina

#25
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

[SiNaN]

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();
Former SMF Core Developer | My Mods | SimplePortal

Sarge

That's cool, [SiNaN] :)

Can you package it as a mod?

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Zitat
<H> I had zero posts when I started posting

[SiNaN]

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
Former SMF Core Developer | My Mods | SimplePortal

Sarge


    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Zitat
<H> I had zero posts when I started posting

[SiNaN]

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?
Former SMF Core Developer | My Mods | SimplePortal

Sarge

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. :)

    Please do not PM me with support requests unless I invite you to.

http://www.zeriyt.com/   ~   http://www.galeriashqiptare.net/


Zitat
<H> I had zero posts when I started posting

Kalina

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. :)

Nibogo

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!!

[SiNaN]

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. :)
Former SMF Core Developer | My Mods | SimplePortal

Eliana Tamerin

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.
Do NOT PM me for support.

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

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

avf

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

[SiNaN]

Former SMF Core Developer | My Mods | SimplePortal

Deprecated

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. ;)


Eliana Tamerin

Compatible With:     1.1.5

Hmm, let's see. No.
Do NOT PM me for support.

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

Low

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. :(

Eliana Tamerin

There is a mod for this now. Why don't you try that?
Do NOT PM me for support.

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

Low

#44
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.

Eliana Tamerin

Go into your Modifications.english.php and move the ?> to the end of the file.
Do NOT PM me for support.

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

Paul123

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

Advertisement: