XF 2.2 What is 'templateOverrides' in $viewParams and how does it work practically?

Earl

Well-known member
I've seen this "templateOverrides' thing in many places such as
Pub\Controller\Thread actionIndex, edit,
Pub\Controller\Forum\actionForum etc

And I see a template name in its value when the debugger is running on a question thread.
gTX113N.png


I've been trying to understand the mechanism here for a week and still, I have no clue about what exactly doing it.

I feel like it has something to do with new template extensions, but what exactly happening here?

I noted this when I try to add a template modification to the thread_list_macros template.
I have added a new function to make suggestions for discussions, and vote on these suggestions, And I was going to modify the thread_list_macros template and add a font awesome icon next to the watched icon, then again I noted this <xf:extension name="before_status_state"></xf:extension> extension has located right where I want to put my own custom font-awesome icon that indicates the discussion has suggestions.

Am I supposed to extend this using this template extension? or just use a find and replace simple template mod?

If I have to extend the template, creating a sub template is not enough, right? I have to put it on PHP code too, where exactly that code is located in PHP?
 
Solution
I feel like it has something to do with new template extensions, but what exactly happening here?
Calling different template/macro based on thread type. It comes from ThreadType Handler. Go to src/XF/ThreadType and review that directory. If you are going to extend functionality/view for a particular thread type, do it in the thread type handler system if possible. I remember some methods in there related to defining FA icons.
I feel like it has something to do with new template extensions, but what exactly happening here?
Calling different template/macro based on thread type. It comes from ThreadType Handler. Go to src/XF/ThreadType and review that directory. If you are going to extend functionality/view for a particular thread type, do it in the thread type handler system if possible. I remember some methods in there related to defining FA icons.
 
Solution
Top Bottom