XF 2.0 Calling upon Custom Thread Fields and Performance Impact

ManagerJosh

Well-known member
What's the proper way of calling about a select number of custom thread fields on showthread (still learning template names) and what's the performance impact generally?
 

Mike

XenForo developer
Staff member
If you're viewing a thread, the thread field values for that thread are already available in $thread.custom_fields. Essentially no overhead.
 

Mike

XenForo developer
Staff member
I believe the information should generally be available there as well without significant overhead. The main detection would probably be by looking at the queries run on a page -- if you start seeing a similar query running over and over, then that would indicate that data is only being loaded on demand.
 

ManagerJosh

Well-known member
I believe the information should generally be available there as well without significant overhead. The main detection would probably be by looking at the queries run on a page -- if you start seeing a similar query running over and over, then that would indicate that data is only being loaded on demand.
If we wanted to show only
Code:
custom_field_1
and
Code:
custom_field_3
but not
Code:
custom_field 2
on the list of all threads?
 

Mike

XenForo developer
Staff member
You'd need to call each value individually ($thread.customer_fields.custom_field_1) wherever you want it to display.
 

ManagerJosh

Well-known member
You'd need to call each value individually ($thread.customer_fields.custom_field_1) wherever you want it to display.
I must be doing something wrong. I inserted the following in and it's not generating the result I was hoping for..

Code:
<xf:macro template="custom_fields_macros" name="custom_fields_view"
                                    arg-type="threads"
                                    arg-group="before"
                                    arg-onlyInclude="{$thread.Forum.field_cache}"
                                    arg-set="{$thread.custom_fields.custom_field_1}"
                                    arg-wrapperClass="message-fields message-fields--before" />
 

Mike

XenForo developer
Staff member
Oh, you're using the macro which is for multiple fields. You need to pass it a set of custom fields then, so $thread.custom_fields. If you want to filter that to multiple fields you can change the onlyInclude argument (provided the format matches the field cache).
 

NHATKYMUA

Member
Oh, you're using the macro which is for multiple fields. You need to pass it a set of custom fields then, so $thread.custom_fields. If you want to filter that to multiple fields you can change the onlyInclude argument (provided the format matches the field cache).
Hi @Mike, @Chris D . I am using $thread.customer_fields.custom_field_1 to display customer field. Its only work if I used text box Field type. If I used Radio buttons, Drop down selection , Multiple-choice drop down ... its just display Value ( value_a_z_0_9_and_only). I like to display Text. How can I do that? please help
 
Top