Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2318

Extension Writers Discussion • Re: Make current user ID globally available in templates

$
0
0
Yup. Thanks. This becomes very easy then.

If the PTB want to add the necessary variable to core, well and good, but in the absence of that I just write the extension and go ahead and use my variable in my templates. If they then add the equivalent to core later, I just change the template logic to take advantage of that and ditch the extension. In the meantime I can have templates that support the custom variable but don't rely it.

For allowing searching your own topics (or allowing others to search your topics) it's just:

Code:

{% if MY_GRANDMAS_CANARY is defined %}<a href="./search.php?author_id={{ MY_GRANDMAS_CANARY }}&sr=topics&sf=firstpost" role="menuitem"><i class="icon fa-file fa-fw" aria-hidden="true"></i><span>{{ definition.GB_MY_TOPICS }}</span></a>{% endif %}
And for displaying something useful in your own postprofile it's just:

Code:

{% if MY_GRANDMAS_CANARY is defined and S_DISPLAY_PM and (postrow.POSTER_ID is same as MY_GRANDMAS_CANARY) %}<dd class="profile-contact"><a href="{{ U_PRIVATEMSGS }}"><i class="icon fa-inbox fa-fw" aria-hidden="true"></i>{{ L_PM }}{% 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">/* The usual phpBB contact stuff */</dd>{% endif %}

Statistics: Posted by Gumboots — Wed Apr 16, 2025 5:47 pm



Viewing all articles
Browse latest Browse all 2318

Trending Articles