[RFC] Template Modify/Replace by Extensions

Note: We are moving the topics of this forum and it will be deleted at some point

Publish your own request for comments/change or patches for the next version of phpBB. Discuss the contributions and proposals of others. Upcoming releases are 3.2/Rhea and 3.3.
Post Reply
User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

[RFC] Template Modify/Replace by Extensions

Post by MattF »

In phpBB 3.0.X MODX files, there were a number of modification methods for modifying the template files that were very commonly used, but are not possible in phpBB 3.1:

[ REPLACE WITH ]
[ REMOVE ]
[ INLINE REPLACE WITH ]
[ INLINE REMOVE ]

As a result, extensions can only add new template code, but can not modify or remove core template code. The current workaround is to hope a block of template code you want to modify or remove has an ID selector, which you can use to manipulate using CSS or JS.

However, a proper/simpler method for changing template code should be provided.

Things that need to be ironed out:
1) The syntax?
2) How it should work, like the EVENTs or some other way (Twig blocks/inheritance?, PHP processing?)
3) What to do when two or more extensions want to modify the same piece of code?

Here's a ticket for this posted a while back:
https://tracker.phpbb.com/browse/PHPBB3-12019
Has an irascible disposition.

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC] Template Modify/Replace by Extensions

Post by MichaelC »

This can be done in the phpBB already by using events to insert conditionals.
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: [RFC] Template Modify/Replace by Extensions

Post by MattF »

MichaelC wrote:This can be done in the phpBB already by using events to insert conditionals.
No, we (EXreaction and I) actually tried that already. It does not work. Trying to use events to insert conditionals just broke things, and left you with half-rendered output. IIRC, it was because each template event is rendered on its own in TWIG, and therefor it appears to have an opened condition that is not properly closed, so poof, broken PHP.
Has an irascible disposition.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Modify/Replace by Extensions

Post by EXreaction »

Which code are you thinking may need total replacing or modification?

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: [RFC] Template Modify/Replace by Extensions

Post by MattF »

EXreaction wrote:Which code are you thinking may need total replacing or modification?
For example, my ABBC3 bbcode extension, needs to completely replace the core's bbcode posting buttons template code with new template code. I had to do it using CSS instead, but that's not ideal as the old template code is still delivered, just not displayed.
Has an irascible disposition.

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Template Modify/Replace by Extensions

Post by brunoais »

Hum... That ain't good... I also need to do the same thing for the WYSIWYG editor :S.

User avatar
tbackoff
Registered User
Posts: 180
Joined: Sat Jun 12, 2010 3:25 am

Re: [RFC] Template Modify/Replace by Extensions

Post by tbackoff »

Have a look at my Search Posts extension. I was able to successfully replace viewtopic's 'POSTER_POSTS' with the code I wanted using a event. Obviously, this means the event has to be in place first.

... or am I completely missing something?

User avatar
brunoais
Registered User
Posts: 964
Joined: Fri Dec 18, 2009 3:55 pm

Re: [RFC] Template Modify/Replace by Extensions

Post by brunoais »

you successfully replaced a variable, not the HTML content that is in the .html file.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Template Modify/Replace by Extensions

Post by EXreaction »

VSE wrote:
EXreaction wrote:Which code are you thinking may need total replacing or modification?
For example, my ABBC3 bbcode extension, needs to completely replace the core's bbcode posting buttons template code with new template code. I had to do it using CSS instead, but that's not ideal as the old template code is still delivered, just not displayed.
That sort of stuff should be more dynamically driven to start with

samwisesk8r
Registered User
Posts: 11
Joined: Sat Aug 23, 2014 7:24 pm

Re: [RFC] Template Modify/Replace by Extensions

Post by samwisesk8r »

Has there been any solution to this after all this time?

Post Reply