XF 2.1 Event listener v.1 vs v.2.1

Kaizen

Member
Looking at finally transitioning from v.1 to v.2, but have a few custom plugins/addons that have to be recreated first.

In that regard, I am wondering if it is still possible to add an event listener to a template?

As an example, this would be from the config in the old xml settings file for the plugin/addon:
Code:
<listener event_id="template_hook" execute_order="999" callback_class="AprilFools_Listener" callback_method="updateRank" active="1" hint="message_user_info_text" description="April Fools - Forum List Rank"/>

I see there is a "code_event_listeners.xml" file in the new "_data" directory, but I cannot find any documentation on how I can add a template listener to an addon.
 
Thanks for the quick reply.

I have taken a look on: https://xenforo.com/xf2-docs/dev/designing-styles/#templates which I assume is part of that system, and it doesn't really have too much information.

Though from my understanding this new system means it is now impossible to have addons that handle dynamic events like "April Fools", i.e. the addon can be enabled prior to 1st of April, and it will only do the modifications when the timezone of the logged in member is 1st of April.

I.e. without having to replace the actual template in question, i.e. just modify the avatar, member title, etc.
 
I have taken a look on: https://xenforo.com/xf2-docs/dev/designing-styles/#templates which I assume is part of that system, and it doesn't really have too much information.
That documentation is mostly directed towards developers who have some previous experience.

Though from my understanding this new system means it is now impossible to have addons that handle dynamic events like "April Fools", i.e. the addon can be enabled prior to 1st of April, and it will only do the modifications when the timezone of the logged in member is 1st of April.
It is still very much possible. Just need to look at the right classes. :P

I.e. without having to replace the actual template in question, i.e. just modify the avatar, member title, etc.
Most of those can be done via XF:User entity and XF\Template\Templater class..
 
Back
Top Bottom