Proposal: new JS functionality to add for extensions

General discussion of development ideas and the approaches taken in the 3.x branch of phpBB. The next feature release of phpBB 3 will be 3.3/Proteus.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.2.x. If you need support for phpBB 3.2.x please visit the 3.2.x Support Forum on phpbb.com.

If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 673
Joined: Mon Mar 08, 2010 9:18 am

Re: Proposal: new JS functionality to add for extensions

Post by VSE »

Trying to handle this using Javascript is the wrong approach. It will be handled in the future using PHP and Twig. For now, ext authors must use CSS and as a last resort JS to modify the DOM, but in the future a PHP solution is planned.
Has an irascible disposition.

User avatar
javiexin
Registered User
Posts: 90
Joined: Thu Dec 22, 2011 10:04 am

Re: Proposal: new JS functionality to add for extensions

Post by javiexin »

VSE wrote:
Sun Aug 02, 2015 9:13 pm
Trying to handle this using Javascript is the wrong approach.
But the only viable one right now...
VSE wrote:
Sun Aug 02, 2015 9:13 pm
It will be handled in the future using PHP and Twig.
This is very good news.
VSE wrote:
Sun Aug 02, 2015 9:13 pm
For now, ext authors must use CSS and as a last resort JS to modify the DOM,
Precisely: CSS cannot be used to move things in the DOM tree, so you are left to JS only.
So we are in agreement: this might not be ideal, but is the ONLY viable method available today to extension authors.
And as such, I think it would be better to do it in a controlled way, rather than each one taking his own approach.

-javiexin

User avatar
javiexin
Registered User
Posts: 90
Joined: Thu Dec 22, 2011 10:04 am

Re: Proposal: new JS functionality to add for extensions

Post by javiexin »

brunoais wrote:
Sat Jul 25, 2015 3:14 pm
You may also replace the HTML files completely in your extension.
How do I do that?
I have tried putting a file named the same as the template to be overridden in the extension styles/prosilver/template folder, but that does not load as expected, so I guess there is something I am missing.
For the record, I am trying to overload posting_poll_body.html, that is in turn included by posting_layout.html and "activated" by pressing a tab that is created in posting_editor.html (also included by posting_layout.html). Posting_layout is included by posting_body.html which is the top level template loaded by the posting page php.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1834
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: Proposal: new JS functionality to add for extensions

Post by DavidIQ »

If it's not working that way then I think it should. Sounds ideal even.
Image

User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 673
Joined: Mon Mar 08, 2010 9:18 am

Re: Proposal: new JS functionality to add for extensions

Post by VSE »

javiexin wrote:
Tue Aug 04, 2015 11:21 am
brunoais wrote:
Sat Jul 25, 2015 3:14 pm
You may also replace the HTML files completely in your extension.
How do I do that?
I have tried putting a file named the same as the template to be overridden in the extension styles/prosilver/template folder, but that does not load as expected, so I guess there is something I am missing.
For the record, I am trying to overload posting_poll_body.html, that is in turn included by posting_layout.html and "activated" by pressing a tab that is created in posting_editor.html (also included by posting_layout.html). Posting_layout is included by posting_body.html which is the top level template loaded by the posting page php.
All you should need to do is use CSS to hide the identifier #poll-panel in your extension. Then just use the posting_layout_include_panel_body event to insert your own thing. This is exactly the way ABBC3 over-rode the posting buttons layout with its own new custom layout.
Has an irascible disposition.

User avatar
javiexin
Registered User
Posts: 90
Joined: Thu Dec 22, 2011 10:04 am

Re: Proposal: new JS functionality to add for extensions

Post by javiexin »

Thanks a lot, this is a good alternative for this case.
If we use those events, then probably the better solution would be setting the S_SHOW_POLL_BOX template var to false, replace it with a custom template var (say S_MY_SHOW_POLL_BOX) and use the posting_layout_include_panel_body and posting_editor_add_panel_tab events to replace the code. Otherwise, the poll tab will not work, as it is using the #poll-panel id to show/hide the panel.

But the question is still there: should this work (replacing a complete template file in an extension) or not? If it should, how? Generic question, not specific to this particular case (that you solved quite nicely, I didn't know about those two events).

Thanks again!
-javiexin

User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 673
Joined: Mon Mar 08, 2010 9:18 am

Re: Proposal: new JS functionality to add for extensions

Post by VSE »

You can not replace a core template file from an extension.
Has an irascible disposition.

User avatar
javiexin
Registered User
Posts: 90
Joined: Thu Dec 22, 2011 10:04 am

Re: Proposal: new JS functionality to add for extensions

Post by javiexin »

VSE wrote:
Wed Aug 05, 2015 3:22 am
You can not replace a core template file from an extension.
Thanks, that is clear. Not what brunoais said though, but I understand.
Thanks again,
-javiexin

EDIT: No wonder I didn't see these events before, they are new in 3.1.6 (although the commit says 3.1.5)!

Post Reply