viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Need some custom code changes to the phpBB core simple enough that you feel doesn't require an extension? Then post your request here so that community members can provide some assistance.

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

NOTE: NO OFFICIAL SUPPORT IS PROVIDED IN THIS SUB-FORUM
SQLnovice
Registered User
Posts: 159
Joined: Thu Oct 10, 2019 5:03 am

viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Post by SQLnovice »

This is a continuation of Gumboots somehow <solved> topic (linked in cabot's quote below). I think it may be very close to having been solved, but if it was, I'm not seeing the same result as they did. My question may be slightly different from that of Gumboots (see title). His OP suggested a test to perform an action if the "post" author was viewing their own post. Mine is if the "topic" author is currently viewing or 'reading' a topic they've authored.

The assumption being, that we know the topic author is Online. We, as moderators, may also know via Who Is Online that they are "reading" a topic in the forum where their authored topic resides. However, is there a way to test if they're actually viewing the topic that they have authored that "I am" currently also viewing?

Our users and moderators have expressed interest in this capability so they know whether there's value in putting forth the immediate effort to reply quickly (as in a live chat session) or not. If the topic author has moved on to reading other forum topics, also in the same forum as the one their authored topic is in, there's less value in replying to the author's topic immediately; like the OP has closed their chat session.
cabot wrote: Sun Dec 22, 2024 9:55 amYou won't see any difference in other users' mini-profiles, but in your own. ^^

Look at your own posts. If you're logged in, the contact link is replaced by a link to the PM inbox.
That result is currently correct.

However, I've tested having the original topic author, another user, login to one of their own authored topics to test the badge change and I think the first IF test only recognizes me as currently logged in,

Code: Select all

{% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POST_AUTHOR_FULL is same as (CURRENT_USERNAME_FULL)) %}
not the original topic author, who is also logged in, both viewing the same topic...the one that they have authored. I tested this further by altering the code to match a mixture of both yours and Gumboots,' with the only noticeable difference being that with his,

Code: Select all

<a href="{{ U_PRIVATEMSGS }}"><i class="icon fa-inbox fa-fw" aria-hidden="true"></i> {L_PM}{% if PRIVATE_MESSAGE_COUNT %}{L_COLON} <strong>[{{ PRIVATE_MESSAGE_COUNT }}]{% endif %}</strong>
				</a>
the PM badge appears as a train/car or whatever that icon is and with yours

Code: Select all

<a href="{{ U_PRIVATEMSGS }}"><span>{{ lang('PRIVATE_MESSAGES') }}</span>{% if PRIVATE_MESSAGE_COUNT %} <strong class="badge">{{ PRIVATE_MESSAGE_COUNT }}</strong>{% endif %}</a>
there is no icon, just the three characters "PMs" instead of the original Contact: %badge caption symbol%

Thus, I am seeing a slight change, but I think the first row IF test isn't testing for the OP topic author in the right way still. Instead, it seems to be looking to identify if "I am" currently viewing a topic that I am currently viewing. The If condition being true, it changes my profile PM badge to something else that the OP topic author can see, but the 'replying' public is left in the dark still. We want the original topic author's badge to change if true.

So, I think we're very close. If the first IF conditional could tell potential "replying" members if the original topic author was reading/viewing the same topic we're both in at the moment, then I too could say that it has been solved.
:mrgreen:
User avatar
Mannix_
Registered User
Posts: 2038
Joined: Sun Oct 25, 2015 2:56 pm
Name: Matt

Re: viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Post by Mannix_ »

You are comparing the post author not topic author. try TOPIC_AUTHOR instead of POST_AUTHOR
Did I helped You? Consider a donation.
New version of phpBB has been released? My styles aren't validated for it yet? Check my page for the latest downloads!
SQLnovice
Registered User
Posts: 159
Joined: Thu Oct 10, 2019 5:03 am

Re: viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Post by SQLnovice »

I tried that one and a bunch of other combinations, but nothing attempted thus far signifies to the other users that the Topic's Author is online any more than the fact that their status shows them to be online...which we already would know based on their online status.

I had my nephew, who is a programmer, look into it and while not a PHP coder he got a little further, he said the biggest problem is that he, like I, don't know what the condition name possibilities are. If we had those, we might be able to mimic the ELSE portion into the IF portion, so if TRUE, we could change the PM badge in a way that everyone could see. Then it would just be a matter of testing to see if the TOPIC AUTHOR was viewing the same title as, the one that they've authored and that we're also viewing. The badge change would be our indicator that we're both here, basically in a live chat session.

Update: We found some of the variable names in viewtopic.php above the root directory, line 780.
User avatar
Talk19Zehn
Registered User
Posts: 917
Joined: Tue Aug 09, 2011 1:10 pm

Re: viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Post by Talk19Zehn »

Hello, and the solution is which one according to your update? Have you made any progress? Helping people will certainly be interested - :)
Private messages = comparative badges are hidden if there are none to count and is basically set to float right / default.
That's why cabot suggested to declare that class new, I think. Your goal is unfortunately still unclear to me, that private messages are "used" to mark an online feature. Also to know who is reading which post / topic.

In my opinion, who reads what has nothing to do with it ....
What do you want to control and in which country based on which legal requirements?
Sorry, I don't understand such a process. Especially as the user can add friends in the personal profile and much more. Particularly for admins and mods and especially for founders, special authorisations apply if permissions are set correctly.
There was / an EXT: Who reads what - or similar. I didn't look for it again, because for me personally such behaviour is not acceptable, -- sorry. And as you say yourself, who is online can be used. Which in today's times ( browser worlds ) often shows no result or wrong results, as we know.

My approach was: mini-profile ( private messages ): Examples
Such another aid ...., if I have understood you correctly.
viewtopic_body.html
ADD before:
<!-- EVENT viewtopic_body_contact_fields_after -->


1) Test

Code: Select all

					{% if S_USER_LOGGED_IN and not S_IS_BOT %}
						{% if S_DISPLAY_PM and S_NOTIFICATIONS_DISPLAY and (postrow.POST_AUTHOR_FULL is same as(CURRENT_USERNAME_FULL)) %}
							<dd class="action-bar compact">
						{% if S_USER_NEW_PRIVMSG %}
							<a href="{U_PRIVATEMSGS}"><span>{L_NEW_MESSAGES}&nbsp;[{S_USER_NEW_PRIVMSG}]</span></a>
							{% elseif S_USER_UNREAD_PRIVMSG %}
								<a href="{U_PRIVATEMSGS}"><span>{L_UNREAD_MESSAGES}&nbsp;[{S_USER_UNREAD_PRIVMSG}]</span></a>
							{% else %}
								<a href="{U_PRIVATEMSGS}"><span>{L_PRIVATE_MESSAGES} </span><strong class="badge<!-- IF not PRIVATE_MESSAGE_COUNT --> hidden<!-- ENDIF -->">{PRIVATE_MESSAGE_COUNT}</strong></a>
						{% endif %}
							</dd>
						{% endif %}
					{% endif %}
2) Test

Code: Select all

					{% set currentUserId = CURRENT_USERNAME_FULL | trim('<a href="./memberlist.php?mode=viewprofile&amp;u=') | split('"')[0] %}
					{% if S_USER_LOGGED_IN and not S_IS_BOT %}
						{% if S_DISPLAY_PM and S_NOTIFICATIONS_DISPLAY and (postrow.POSTER_ID is same as currentUserId) %}
							<dd class="profile-inbox" data-skip-responsive="true">
						{% if S_USER_NEW_PRIVMSG %}
							<a href="{U_PRIVATEMSGS}" role="menu">
								<i class="icon fa-envelope fa-fw faa-shake animated icon-red" aria-hidden="true"></i><span>{L_NEW_MESSAGES}&nbsp;[{S_USER_NEW_PRIVMSG}]</span>
							</a>
							{% elseif S_USER_UNREAD_PRIVMSG %}
								<a href="{U_PRIVATEMSGS}" role="menu">
									<i class="icon fa fa-envelope-square fa-fw icon-red" aria-hidden="true"></i><span>{L_UNREAD_MESSAGES}&nbsp;[{S_USER_UNREAD_PRIVMSG}]</span>
								</a>
							{% else %}
								<a href="{U_PRIVATEMSGS}" role="menu">
									<i class="icon fa-share fa-fw" aria-hidden="true"></i><span>{L_PRIVATE_MESSAGES} </span><strong class="badge<!-- IF not PRIVATE_MESSAGE_COUNT --> hidden<!-- ENDIF -->">{PRIVATE_MESSAGE_COUNT}</strong>
								</a>
						{% endif %}
							</dd>
						{% endif %}
					{% endif %}
No guarantee and best wishes for your goal. ;)

Edit: 2) = role ....
User avatar
Anișor
Translator
Posts: 361
Joined: Tue Jan 08, 2013 9:36 pm
Location: Angus, Scotland 🏴󠁧󠁢󠁳󠁣󠁴󠁿

Re: viewtopic-body.html - IF topic author is currently viewing a topic they have authored

Post by Anișor »

You can use something like this in viewtopic.php:
'U_TOPIC_POSTER' => ($topic_data['topic_poster'] == $user->data['user_id']) ? true : false,
After:
'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false,

Then in the template:

Code: Select all

				{% if postrow.U_TOPIC_POSTER %}
				<p>I am viewing my own topic</p>
				{% endif %}

Return to “phpBB Custom Coding”