XF 2.2 Show Custom Thread Fields In Thread Listing

Foxtrek_64

Active member
Licensed customer
As it says on the tin-

I want to show a particular custom thread field in the thread listing. Is such possible out of the gate or would I need to modify the template?
 
Solution
It needs a template edit or modification

Depending on how you want it to show, in template thread_list_macros you could try this:

Find
<ul class="structItem-parts">

And add this (where "ID" is the custom thread field ID)



Code:
   <xf:if is="$thread.custom_fields.ID">
                    <li>Price: {$thread.custom_fields.ID}</li>
                </xf:if>

Alternatively it could go under structItem-cell--latest or structItem-cell--meta
Like a "favorite x" in the postbit info? Above or below post? Both are possible. But I'm on mobile for a couple days, so hopefully someone else can screenshot it.
 
Like a "favorite x" in the postbit info? Above or below post? Both are possible. But I'm on mobile for a couple days, so hopefully someone else can screenshot it.
I have it displaying in the thread view like I want it, but I need it to display in the thread listing i.e. when you're viewing the list of threads in the forum.
 
It needs a template edit or modification

Depending on how you want it to show, in template thread_list_macros you could try this:

Find
<ul class="structItem-parts">

And add this (where "ID" is the custom thread field ID)



Code:
   <xf:if is="$thread.custom_fields.ID">
                    <li>Price: {$thread.custom_fields.ID}</li>
                </xf:if>

Alternatively it could go under structItem-cell--latest or structItem-cell--meta
 
Last edited:
Solution
It needs a template edit or modification

Depending on how you want it to show, in template thread_list_macros you could try this:

Find
<ul class="structItem-parts">

And add this (where "ID" is the custom thread field ID)



Code:
   <xf:if is="$thread.custom_fields.ID">
                    <li>Price: {$thread.custom_fields.ID}</li>
                </xf:if>

Alternatively it could go under structItem-cell--latest or structItem-cell--meta
Thanks, I'll give this a shot when I'm home from work
 
Came up with the following. It mostly works except for the coloring on the owned threads. Anyone know what I'm looking at here, and/or have any nits/suggestions?

PHP:
<li>
    <xf:if is="$thread.custom_fields.ticketOwner">
        <div class="structItem-minor">
            <xf:if is="$xf.visitor.username == $thread.custom_fields.ticketOwner">
                {{ phrase('application_claimed_by') }}: <span style="color: {$xf-paletteAccent2}">{$thread.custom_fields.ticketOwner}</span>
            <xf:else />
                {{ phrase('application_claimed_by') }}: {$thread.custom_fields.ticketOwner}
            </xf:if>
        </div>
        <xf:else />
        <div class="structItem-minor">
            <span style="color: red;">{{ phrase('application_unclaimed') }}</span>
        </div>
    </xf:if>
</li>
 
Wrap whatever you want coloured in a div with a class you can style in extra.less. Easier to cope with that what you have done here with the inline style.
 
Last edited:
Wrap whatever you want cored in a div with a class you can style in extra.less. Easier to cope with that what you have done here with the inline style.
In my style properties under basic colors, there's an "error message text color." How can I find the corresponding css variable?

1714075579059.webp
 
As an update-
This has been moved to a widget. The thread list macro now does this:

PHP:
<xf:if is="in_array({$forum.node_id}, [14,16,17,18,20,15])">
    <li><xf:widget key="thread_ticketOwner" /></li>
</xf:if>

And here's the widget code:
PHP:
<xf:if is="$thread.custom_fields.ticketOwner">
    <div class="structItem-minor">
        <xf:if is="$xf.visitor.username == $thread.custom_fields.ticketOwner">
            {{ phrase('application_claimed_by') }}: <div class="application-claimOwn">{$thread.custom_fields.ticketOwner}</span>
        <xf:else />
            {{ phrase('application_claimed_by') }}: {$thread.custom_fields.ticketOwner}
        </xf:if>
    </div>
<xf:else />
    <div class="structItem-minor">
        <div class="application-unclaimed">{{ phrase('application_unclaimed') }}</span>
    </div>
</xf:if>

What I'm noticing is that regardless of the value of $thread.custom_fields.ticketOwner, the thread listing continues to show the application_unclaimed text.

Clearing caches for threads or forums doesn't seem to do anything, but I'm wondering if this is a caching issue. What can I do to diagnose this?
 
Back
Top Bottom