XF 2.0 Multiple username links in datarow

AndyB

Well-known member
In a template I have the following foreach loop which uses a multidimensional array called $results.

The following code does not work:

Code:
<xf:foreach loop="$results" value="$result">
    <xf:datarow rowclass="dataList-row--noHover">
        <xf:cell href="{{ link('members', $result.seller_id) }}">{$result.seller_name}</xf:cell>
        <xf:cell href="{{ link('members', $result.buyer_id) }}">{$result.buyer_name}</xf:cell>
    </xf:datarow>
</xf:foreach>


1507960282917.webp

Normally there's only one username column and I could use $result which would contain a user_id in the array.

Code:
<xf:foreach loop="$results" value="$result">
    <xf:datarow rowclass="dataList-row--noHover">
        <xf:cell href="{{ link('members', $result) }}">{$result.seller_name}</xf:cell>
    </xf:datarow>
</xf:foreach>


But in this case I can't use user_id, I need to use seller_id and buyer_id so I can distinguish between two usernames.

How can I have two username links in one row?

Thank you.
 
Last edited:
It's unlikely that you could use $result there, at least in a way that is correct/expected. I don't know what your $result value is, but I presume it's an entity. You would need to define relations for both the users you are referring to and call those relations in your template. Look at how the thread entity handles the thread starter and the last post user (or the first and last posts in the thread).
 
Back
Top Bottom