[3.3][RC] Group 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!
Suggested Hosts
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)
Mohammed AlSarsawi
Registered User
Posts: 72
Joined: Fri Mar 03, 2017 1:35 pm

Re: [RC] Group Template Variables

Post by Mohammed AlSarsawi »

yes now it's working thank you
User avatar
Galixte de EzCom
Registered User
Posts: 1106
Joined: Mon Oct 04, 2004 11:14 pm
Location: France
Name: Raphaël M.
Contact:

Re: [RC] Group Template Variables

Post by Galixte de EzCom »

Is this extension inside the new version of Custom Code extension?

Could you update the first post of this topic about the Custom Code information?
Communau EzCom
📖 « Traductions d’extensions & styles pour phpBB 3.2.x & 3.3.x ».
📋 Lists of all extensions identified for phpBB 3.1.x & 3.2.x.
📋 Lists of all styles identified for phpBB 3.1.x & 3.2.x.
Image Tu as un forum et tu veux aussi un site web ? Regarde par ici.
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [RC] Group Template Variables

Post by martti »

Galixte de EzCom wrote: Sun Jun 10, 2018 10:13 pm Is this extension inside the new version of Custom Code extension?

Could you update the first post of this topic about the Custom Code information?
It's update now, thanks.

You need to install this Group Template Variables extension if you want the functionality in Custom Code.
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Group Template Variables

Post by martti »

This extension is updated to version 0.2.0
The requirements are now
  • phpBB 3.2.1+
  • PHP 7+
The group ids are now available under the associative template variable marttiphpbb_grouptempvars
This makes it possible to list all group ids:

Code: Select all

<div class="panel">
  <h3>
    all group ids:
  </h3>
  <p>
    {%- for group_id, value in marttiphpbb_grouptempvars -%}
      {{- group_id -}}
    	{%- if not loop.last -%},&nbsp;{%- endif -%}
    {%- endfor -%}
  </p>
</div>
Image

The Custom Code extension is used here to put this contents in template event overall_header_content_before:

Image

To selective show content you can do this now:

Code: Select all

{%- if marttiphpbb_grouptempvars.4 -%}
    This content is only visible when the user is in group with id 4.
{%- endif -%}
In the previous version (for phpBB 3.1) of this extension the variables were available in the form of:

Code: Select all

S_GROUP_ID
Where ID was to be replaced with the id number of the group.
This format is still available but depreciated.
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: [3.2][RC] Group Template Variables

Post by Toxyy »

Martti, this is great. Just used this on a forum to only show the new topic button for administrators in specific forums. The forum uses php 5.5, and it still works. I had to edit ext.php and both of the composer files to get it to install, but the template variables do still appear. Not sure what will break because of that but I don't care much.

Thanks again!
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Group Template Variables

Post by martti »

I simply don't want to care to garantee it works in PHP 5, also PHP7 has some features I use all the time now. It could be that this works because it's a simple extension, but I won't garantee it.
User avatar
Toxyy
Registered User
Posts: 942
Joined: Mon Oct 24, 2016 3:22 pm
Location: Namek
Contact:

Re: [3.2][RC] Group Template Variables

Post by Toxyy »

martti wrote: Wed Jun 27, 2018 8:49 pm I simply don't want to care to garantee it works in PHP 5, also PHP7 has some features I use all the time now. It could be that this works because it's a simple extension, but I won't garantee it.
That's what I was thinking, it's small enough that if something does break I can take a look, but all seems to be well. Either way, thanks for allowing me to do my job.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

Some of my extensions:
[3.3][BETA] Post Form Templates || [3.3][BETA] Anonymous Posts || [3.2][3.3][BETA] ACP Merge Child Forums || [3.2][BETA] Sticky Ad || [3.2][DEV] User Delete Topics || [3.3][DEV] Moderate While Searching || [3.3][RC] Short Number Twig Extension
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

hi, just a little digging of this nice extension here... ;)

any idea why it seems not to work in certain pages? on my board app.php/help/faq for example, groups do not sho and i try to debug a little, this line: https://github.com/marttiphpbb/phpbb-ex ... er.php#L53 returns false, i cant explain why.

i have the mchat extension installed as well, and neither does it work there.
Joey: How' do you think she's doin' ??
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Group Template Variables

Post by martti »

pataluc wrote: Sun Mar 17, 2019 10:41 pm hi, just a little digging of this nice extension here... ;)

any idea why it seems not to work in certain pages? on my board app.php/help/faq for example, groups do not sho and i try to debug a little, this line: https://github.com/marttiphpbb/phpbb-ex ... er.php#L53 returns false, i cant explain why.

i have the mchat extension installed as well, and neither does it work there.
It works for me. Maybe there's an extension that unsets the user id on this page?
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

i have echoed the $sql variable to test it, and the query seemed ok to me regardless of the page i browse...

i'm gonna try with a empty forum from scratch to test it again.
Joey: How' do you think she's doin' ??
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

i launched a fresh new board using this docker image (https://hub.docker.com/r/bitnami/phpbb)...

i installed your extension, and just pasted:

Code: Select all

<div class="panel">
  <h3>
    all group ids:
  </h3>
  <p>
    {%- for group_id, value in marttiphpbb_grouptempvars -%}
      {{- group_id -}}
    	{%- if not loop.last -%},&nbsp;{%- endif -%}
    {%- endfor -%}
  </p>
</div>
in the overall_head.html, purged the cache.

on the board index:
Image

on the FAQ:
Image

i suspect that it has something to do with the FAQ being a route (symfony route i guess?), with "/app.php/help/faq" as url, instead of a plain old php file like the index of the board...
Joey: How' do you think she's doin' ??
User avatar
martti
Registered User
Posts: 911
Joined: Thu Jul 31, 2014 8:23 am
Location: Belgium

Re: [3.2][RC] Group Template Variables

Post by martti »

Using the same code, phpBB 3.2.5, on my local machine (Ubuntu 18.04) with the PHP development server (PHP 7.3) I get this for http://localhost:8888/app.php/help/faq:

Image
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

are you on sqlite? i just reinstalled my board on sqlite, and i have indeed the groups on the FAQ. just before, on mysql, I set mysql to log every query, and i can see that no query is sent when on FAQ...

all i need to do now is find why! :mrgreen:
Joey: How' do you think she's doin' ??
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

made some progress here...

i finally understood that the connection is closed, and that's why i don't get the result... (took me long enough ^^)

i hooked the phpbb/db/driver/mysqli.php and add a

Code: Select all

debug_print_backtrace();
at the beginning of the _sql_close() function, and i got :

Code: Select all

#0  phpbb\db\driver\mysqli->_sql_close() called at [/var/www/html/phpbb/db/driver/driver.php:248]
#1  phpbb\db\driver\driver->sql_close() called at [/var/www/html/phpbb/db/driver/factory.php:393]
#2  phpbb\db\driver\factory->sql_close() called at [/var/www/html/includes/functions.php:4784]
#3  garbage_collection() called at [/var/www/html/includes/functions.php:4747]
#4  page_footer(1, , ) called at [/var/www/html/phpbb/controller/helper.php:95]
#5  phpbb\controller\helper->render(faq_body.html, Frequently Asked Questions) called at [/var/www/html/phpbb/help/controller/controller.php:74]
#6  phpbb\help\controller\controller->handle() called at [/var/www/html/vendor/symfony/http-kernel/HttpKernel.php:135]
the connection is closed in the garbage_collection() function, which is never called in index.php... so apparently the event twig_environment_render_template_before that you use is triggered after that.

i'm not sure where to go from here... ;)
Joey: How' do you think she's doin' ??
pataluc
Registered User
Posts: 7
Joined: Fri May 21, 2004 1:15 pm

Re: [3.2][RC] Group Template Variables

Post by pataluc »

Joey: How' do you think she's doin' ??
Post Reply

Return to “Extensions in Development”