[3.2][BETA] All Users Groups Template Variables

A place for Extension Authors to post and receive feedback on Extensions still in development. No Extensions within this forum should be used within a live environment!
Scam Warning
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: Extensions Development rules

IMPORTANT FOR NEEDED EVENTS!!!
If you need an event for your extension please read this for the steps to follow to request the event(s)
User avatar
martti
Registered User
Posts: 914
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

[3.2][BETA] All Users Groups Template Variables

Post by martti »

In response to this request.
jackennils wrote: Sat Apr 28, 2018 11:47 am...
Extension Name: All Users Groups Template Variables
Author: martti
Extension Description: This extension provides Template variables that can be used to check if the users in the views belong to certain groups.

Example In Viewtopic


To check if the poster in a postrow belongs to a certain group

Code: Select all

{%- if marttiphpbb_allusersgroupstempvars[postrow.POSTER_ID][GROUP_ID] -%}
    This content is only visible if the poster belongs to group GROUP_ID (replace GROUP_ID with the group number)
{%- endif -%}
To get all id's of groups a poster belongs to (comma separated list):

Code: Select all

{%- for group_id, boolean_true in marttiphpbb_allusersgroupstempvars[postrow.POSTER_ID] -%}
    {{- group_id -}}{% if not loop.last -%}, {% endif -%}
{%- endfor -%}
See the README.md for examples in other views.

Extension Version: 0.1.0
Requirements: phpBB 3.2 PHP 7+
Extension Download: https://github.com/marttiphpbb/phpbb-ex ... master.zip The files are to be put into ext/marttiphpbb/allusersgroupstempvars
Github repository: https://github.com/marttiphpbb/phpbb-ex ... pstempvars
Languages: no language files included
Templates: no template files included
Screenshot:

The second example above (all group id's of the poster) in the template event viewtopic_body_post_author_before:

Image
Last edited by martti on Sun Apr 29, 2018 7:49 am, edited 3 times in total.
User avatar
martti
Registered User
Posts: 914
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] All Users Groups Template Variables

Post by martti »

martti wrote: Sat Apr 28, 2018 10:12 pm ...
Whoops, I just wanted to edit the first post, but did a reply by mistake.
User avatar
jackennils
Registered User
Posts: 229
Joined: Mon Jun 01, 2009 7:48 pm

Re: [3.2][BETA] All Users Groups Template Variables

Post by jackennils »

Just checked it and it works very good. Thank you!

How about support for ucp_pm_viewmessage where it is not POSTER_ID, not USER_ID but AUTHOR_ID?
User avatar
martti
Registered User
Posts: 914
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] All Users Groups Template Variables

Post by martti »

Ok I've add this one too. Let me know it there are others.

UCP PM Viewmessage

Code: Select all

    {%- if marttiphpbb_allusersgroupstempvars[AUTHOR_ID][GROUP_ID] -%}
        This content is only visible if the author belongs to group GROUP_ID (replace GROUP_ID with the group number)
    {%- endif -%}
AUTHOR_ID is added by the extension; it is not available in core.
User avatar
jackennils
Registered User
Posts: 229
Joined: Mon Jun 01, 2009 7:48 pm

Re: [3.2][BETA] All Users Groups Template Variables

Post by jackennils »

It works! This now fulfills all my needs.

Honestly, I really appreciate your help. Thank you very very much. :)
User avatar
John Rambo
Registered User
Posts: 84
Joined: Tue Jun 18, 2013 8:46 pm

Re: [3.2][BETA] All Users Groups Template Variables

Post by John Rambo »

I have to say that you make some beautiful extensions thanks 👏
User avatar
MarkDHamill
Registered User
Posts: 4933
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA

Re: [3.2][BETA] All Users Groups Template Variables

Post by MarkDHamill »

I've been trying this extension. What's wrong with this markup in viewtopic_body.html? The extension is enabled and it seemed to work fine in a test environment, but failed when moved to production. I am trying to suppress an ad if the user is in groups 17 and 9, but the ad appears.

Code: Select all

<!-- BEGIN postrow -->
        <!-- IF postrow.S_ROW_COUNT % 10 == 0 -->
                {% if not marttiphpbb_allusersgroupstempvars[postrow.USER_ID][17] and not marttiphpbb_allusersgroupstempvars[postrow.USER_ID][9] %}
                <!-- ad markup -->
                {% endif %}
        <!-- ENDIF -->
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.
User avatar
martti
Registered User
Posts: 914
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][BETA] All Users Groups Template Variables

Post by martti »

MarkDHamill wrote: Fri Aug 24, 2018 2:04 am I've been trying this extension. What's wrong with this markup in viewtopic_body.html? The extension is enabled and it seemed to work fine in a test environment, but failed when moved to production. I am trying to suppress an ad if the user is in groups 17 and 9, but the ad appears.

Code: Select all

<!-- BEGIN postrow -->
        <!-- IF postrow.S_ROW_COUNT % 10 == 0 -->
                {% if not marttiphpbb_allusersgroupstempvars[postrow.USER_ID][17] and not marttiphpbb_allusersgroupstempvars[postrow.USER_ID][9] %}
                <!-- ad markup -->
                {% endif %}
        <!-- ENDIF -->
  • In viewtopic there is no postrow.USER_ID. It's postrow.POSTER_ID
  • But that would represent the user that posted the post, not the actual user viewing.
  • If you only need the current user viewing the page, you could use the extension Group Template Variables
User avatar
MarkDHamill
Registered User
Posts: 4933
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA

Re: [3.2][BETA] All Users Groups Template Variables

Post by MarkDHamill »

Thank you. The two extensions looked so similar I thought they were the same thing.
Need phpBB services or a phpBB consultant? I offer most phpBB services. Getting lost managing phpBB? Buy my book, Mastering phpBB Administration. Covers through phpBB 3.3.7. eBook and paper versions available.

Return to “Extensions in Development”