XF 2.0: please make all classes extendable

Arty

Well-known member
In XenForo 1 there are few classes that cannot be extended. Recently I ran into inability to extend XenForo_Template_FileHandler and
XenForo_Template_Public. Those limitations make it impossible to write add-ons that modify templates at compile time rather than run time, which might affect performance if modifications require a lot of parsing.

Changing it for XF 1 would require too many core changes, so probably not worth doing it now. Can you please make all classes extendable in XenForo 2.0, so it would be possible to change pretty much any part of XenForo?
 
Upvote 2
FWIW, modifying templates at compile time by add-ons is generally something we have tried to avoid, simply because we intentionally don't run extended classes while upgrading (so compiler extension can block an upgrade). This is why we tend to push to run-time things or the template modification system which is something we can more easily control (since it's not modifying the compiler itself).

I'm going to close this suggestion but not give it a particular prefix. The reason is that when a suggestion says "do something for ALL things", it's very difficult to ever consider it implementable. There may be specific reasons why a decision was made (I gave some potential examples with respect to the compiler, for example), it may be an oversight or something else. Specific, actionable suggestions are more likely to be implemented by virtue of the fact that they're concrete, rather than conceptual.

That said, we are certainly aware of the use of statics in XF1 in some non-ideal places so we've taken steps to remove them in most situations. We're certainly aware of the general idea of what you're suggesting and have been taking it into consideration. But it'll be much more useful to suggest specific examples with an explanation of why/what you're trying to do if you run into them in XF2.
 
Thank you.

What I'm trying to do in XF1 is to make style specific template modifications. While it can be done in run time using template_post_parse event, it could be resource intensive to do that every time template is rendered, so I was looking at possibility to mess with compiled templates instead. That would require extending classes XenForo_Template_Public (to alter compiled templates) and XenForo_Template_FileHandler (to change altered compiled templates when parent template is changed/deleted).
 
$visitorStyle holds information about the current style and should be available in all templates. You mention template modifications, so I'm not sure if you're referring to the system by that name, but if so, you should be able to create modifications that only apply based on the value within that.
 
That wouldn't work because there is no fixed style id or name to test against. I need to apply modification to all styles that have specific style property. There is no function to check if property exists, using template condition will trigger error if property is missing.

Why do I want that? Currently to provide support for third party add-on in my style I need to supply modified templates with style. Some add-ons have quite frequent updates that don't change more than few lines of code. Maintaining support for those add-ons requires updating modified templates with every update, which also ties my styles to specific versions of those add-ons.

My idea is to move support for third party add-ons from style to template modifications. Since my styles already come with optional add-on that enhances some XenForo features, I want to add template modifications functionality to my add-on, so instead of providing templates for third party add-ons, my add-on would apply necessary template modifications for third party add-ons to my styles. This will help a lot with maintaining support for third party add-ons and will make it possible to support multiple versions of same third party add-on.

So that is why I was looking for possibility to create template modifications that are applied only to specific style.
 

Similar threads

Back
Top Bottom