We'd like to add some custom functionality for things like what avatar is used in thread view. Specifically, we'd like to output a few canonical images instead of the avatars for certain tags, like a special image for a "news" tag, or one for a "video games" tag, etc.
At this point I'm relatively comfortable with making changes via template modifications - but rather than store some logic in a template (thread_list, in this case) and then potentially having to duplicate it elsewhere, seems like ideally there woudl be a good place I could put a function (with a tag name parameter, have a switch statement that returns a specific image path, or null if the avatar should be used). Then in the template itself, there could just be a basic conditional to 1) call that function, and 2) use the avatar as usual if null.
Is this a thing in XF? Is there a canonical way you'd create custom functions and then call them somehow? Or is the logic meant to be stored in each template? There's other modifications we'd like to make as well, just want to make sure we're adding code in the best places to minimalize problems later.