[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!
Ideas Centre
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)
Post Reply
User avatar
martti
Registered User
Posts: 765
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

[3.2][BETA] All Users Groups Template Variables

Post by martti » Sat Apr 28, 2018 10:12 pm

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: 765
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

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

Post by martti » Sun Apr 29, 2018 7:23 am

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: 214
Joined: Mon Jun 01, 2009 7:48 pm

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

Post by jackennils » Sun Apr 29, 2018 12:34 pm

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: 765
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

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

Post by martti » Sun Apr 29, 2018 4:54 pm

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: 214
Joined: Mon Jun 01, 2009 7:48 pm

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

Post by jackennils » Sun Apr 29, 2018 6:27 pm

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: 74
Joined: Tue Jun 18, 2013 8:46 pm

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

Post by John Rambo » Mon Apr 30, 2018 9:20 am

I have to say that you make some beautiful extensions thanks 👏

User avatar
MarkDHamill
Registered User
Posts: 3959
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

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

Post by MarkDHamill » 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 -->
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

User avatar
martti
Registered User
Posts: 765
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

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

Post by martti » Fri Aug 24, 2018 9:41 am

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: 3959
Joined: Fri Aug 02, 2002 12:36 am
Location: Florence, MA USA
Contact:

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

Post by MarkDHamill » Fri Aug 24, 2018 12:01 pm

Thank you. The two extensions looked so similar I thought they were the same thing.
Get the latest versions of my Digests and Smartfeed extensions.
Need phpBB services or a phpBB consultant? I offer most phpBB services.

Post Reply

Return to “Extensions in Development”