Code: Select all
<!-- IF MUPPET_STARING_AT_THIS.POSTED_IT -->Do stuff here<!-- ENDIF -->
Edited topic title for typo.
Code: Select all
<!-- IF MUPPET_STARING_AT_THIS.POSTED_IT -->Do stuff here<!-- ENDIF -->
POST_AUTHOR_FULL
and CURRENT_USERNAME_FULL
?
Code: Select all
{% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POST_AUTHOR_FULL is same as(CURRENT_USERNAME_FULL)) %}
<dd class="profile-pm-inbox">
<a href="{{ U_PRIVATEMSGS }}">
<span>{{ lang('PRIVATE_MESSAGES') }}</span>{% if PRIVATE_MESSAGE_COUNT %} <strong class="badge">{{ PRIVATE_MESSAGE_COUNT }}</strong>{% endif %}
</a>
</dd>
{% elseif not S_IS_BOT and postrow.contact %}
<dd class="profile-contact">
{# ... #}
</dd>
{% endif %}
.profile-pm-inbox:has(.badge)
selector to, among other things, overwrite the overflow/hidden on dd
and fine-tune the alignment and colour of the badge.Yes, that was what I was expecting. Comparing the whole box of frogs is messy, and ID would be much simpler. Obviously the software keeps track of post author ID and current user ID, so it's just a question of if those variables can be made available directly in the template.cabot wrote: Sun Aug 18, 2024 1:14 pm Yup, comparing user ID would be ideal and safer than comparing those strings returned by template var. :/
I personally can't think of a use case, but as you said others may have a need. For now, a small extension should be able to accomplish this. All you really need to do is hoot into an event loaded on each page (Gumboots wrote: Sun Aug 18, 2024 9:04 pm If there is absolutely no way of getting {CURRENT_USER_ID} in the template with current core code, I think I will suggest it in phpBB Ideas. It's an obvious global variable to have available, with a range of potential uses. Cleaning up useless contact details and replacing them with something useful is just one use case. I'm sure people could think of a dozen more without too much difficulty.
page_header
, for example) and assign code like so:Code: Select all
$this->template->assign_var('CURRENT_USER_ID', $this->user->data['user_id']);
Code: Select all
{% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POST_AUTHOR_FULL is same as (CURRENT_USERNAME_FULL)) %}
<dd class="profile-inbox">
<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>
</dd>
{% elseif not S_IS_BOT and postrow.contact %}
CURRENT_USER_ID
variable. This also works...Code: Select all
{% set currentUserId = CURRENT_USERNAME_FULL | trim('<a href="./memberlist.php?mode=viewprofile&u=') | split('"')[0] %}
{% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POSTER_ID is same as currentUserId) %}
<dd class="profile-inbox">
postrow.POSTER_ID
instead of postrow.POST_AUTHOR_FULL
. On other other hand, it relies on running trim and split on CURRENT_USERNAME_FULL
first, before running the comparison with postrow.POSTER_ID
, so whether it's actually better or not is anyone's guess.split('"')[0]
seemed better. It avoids having to use wildcards to deal with the inline style for username colour.Gumboots wrote: Tue Aug 20, 2024 3:04 am After figuring this one out - viewtopic.php?t=2655820 - I tried an alternative method of dealing with the lack of aCURRENT_USER_ID
variable. This also works...
It's cleaner in one sense, in that it just callsCode: Select all
{% set currentUserId = CURRENT_USERNAME_FULL | trim('<a href="./memberlist.php?mode=viewprofile&u=') | split('"')[0] %} {% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POSTER_ID is same as currentUserId) %} <dd class="profile-inbox">
postrow.POSTER_ID
instead ofpostrow.POST_AUTHOR_FULL
. On other other hand, it relies on running trim and split onCURRENT_USERNAME_FULL
first, before running the comparison withpostrow.POSTER_ID
, so whether it's actually better or not is anyone's guess.
Obviously you could run trim twice, but the cleaner syntax ofsplit('"')[0]
seemed better. It avoids having to use wildcards to deal with the inline style for username colour.
Anyway, this works. Functionally it's identical to Cabot's solution, but since I had to play with this stuff to figure out something else I thought I'd use this solution.
Code: Select all
{% EVENT viewtopic_body_online_list_after %}
<!-- INCLUDE overall_footer.html -->
cabot wrote: Sun Aug 18, 2024 10:07 am Hello,
By using Twig same as onPOST_AUTHOR_FULL
andCURRENT_USERNAME_FULL
?You'll then need to adjust the style using theCode: Select all
{% if S_REGISTERED_USER and S_DISPLAY_PM and (postrow.POST_AUTHOR_FULL is same as(CURRENT_USERNAME_FULL)) %} <dd class="profile-pm-inbox"> <a href="{{ U_PRIVATEMSGS }}"> <span>{{ lang('PRIVATE_MESSAGES') }}</span>{% if PRIVATE_MESSAGE_COUNT %} <strong class="badge">{{ PRIVATE_MESSAGE_COUNT }}</strong>{% endif %} </a> </dd> {% elseif not S_IS_BOT and postrow.contact %} <dd class="profile-contact"> {# ... #} </dd> {% endif %}
.profile-pm-inbox:has(.badge)
selector to, among other things, overwrite the overflow/hidden ondd
and fine-tune the alignment and colour of the badge.