Override view helper?

Liam W

in memoriam 1998-2020
Is there a way I could override/extend a view helper class?

I tried using the load_class_view but it doesn't seem to be working...
 
No, you can't, unfortunately.

Can you do what you need to do by extending the classes which call it?
 
No, you can't, unfortunately.

Can you do what you need to do by extending the classes which call it?

Yes, I guess. Dunno if it is technically the right way to do it though - I would have to make it use my class instead of xenForo's class - would that be OK?
 
Not really.

That has the potential to clash with other add-ons wanting to do similar things. If it's the absolute only way you can do it then there's perhaps not many other options.

You could share here what you're trying to do then me or someone else might be able to tell you if there's other ways to achieve it.
 
and @Liam W don't forget to call the parent method!
ATM your sig addon will break all other addons which are overriding the same view classes because they won't be called.
 
and @Liam W don't forget to call the parent method!
ATM your sig addon will break all other addons which are overriding the same view classes because they won't be called.

Added in for the next version....

(Does it matter where the parent call goes? I added it at the top.)
 
(Does it matter where the parent call goes? I added it at the top.)

In this case not really but there are several scenarios, where it matters.

e.g. controller actions, model methods, etc.....


the views are really special because there's not allways a real view class... many views are just fakes, so you can't call parent::renderHtml without checking if it's callable, see also this problem http://xenforo.com/community/threads/renderhtml-in-fakebase-classes.48133/
 
Back
Top Bottom