XF 1.5 Xen Coding For Thread Links

I've searched and can't find how to make this work:
Code:
<a href="{xen:link 'threads', $thread}">Link to thread</a>

We using the following on a template, but it keeps link to the index page instead of the thread:
Code:
<a href="{xen:link 'threads', 10064}">Link to thread</a>

We even tried this, but it links to an error page:
Code:
<a href="{xen:link 'threads', $thread.10064}">Link to thread</a>

UPDATE
Think we figured it out. This seems to work:
Code:
<a href="{xen:link 'threads',  $thread, 'thread_id=10064'}">Link to thread</a>
 
Last edited:
Oh wait, I ddin't mean \XF\Entity\Thread. This is clearly XF 1 and not 2. I've had my mind soaked in XF 2 since 2017, heh.

This is what works:
HTML:
<a href="{xen:link 'threads', $thread}">Link to thread</a>

And the $thread has to be an array containing these values (but can contain more):
PHP:
$thread = [
    'thread_id' => 42, // Whatever thread ID
    'title' => 'Thread title', // Whatever thread title (Optional)
];
Can you show more of your code? I'd like to see your controller action in particular and the relevant parts of the template.
 
We're using the Nodes As Tabs add-on, which said to copy this to add links to a drop-down tab:

Code:
<ul class="secondaryContent blockLinksList">
    <xen:if is="{$nodeTab.nat_markread} AND {$visitor.user_id} AND {$selected}">
    <li><a href="{xen:link 'forums/-/mark-read', $forum, 'date={$serverTime}'}" class="OverlayTrigger">{xen:phrase mark_forums_read}</a></li>
    </xen:if>

    <xen:comment>THESE ARE EXAMPLES OF HARD-CODED SECONDARY LINKS</xen:comment>
    <xen:comment>
    <li><a href="{xen:link 'url1'}">Text1</a></li>
    <li><a href="{xen:link 'url2'}">Text2</a></li>
    </xen:comment>

    {xen:raw $childLinks}
</ul>

We changed it a little to suit what we needed, but this is what we have now:
Code:
<div class="primaryContent menuHeader">
    <h3>Rules & FAQ</h3>
</div>
    <ul class="secondaryContent blockLinksList">
        <li><a href="{xen:link 'threads',  $thread, 'thread_id=10064'}">Sites Rules</a></li>
        <li><a href="{xen:link 'threads',  $thread, 'thread_id=10062'}">Image Rules</a></li>
        <li><a href="{xen:link 'threads',  $thread, 'thread_id=10061'}">Chat Rules</a></li>
        <li><a href="{xen:link 'threads',  $thread, 'thread_id=10066'}">Frequently Asked Questions</a></li>
    </ul>

That's pretty much the entire template. :/
 
This is all you need to link to a thread in a template:
HTML:
<a href="{xen:link 'threads/xen-coding-for-thread-links.169941/'}">Some Thread</a>


Just load the thread in the browser and copy everything from the URL from threads on:
1569338323482.png
 
This is all you need to link to a thread in a template:
HTML:
<a href="{xen:link 'threads/xen-coding-for-thread-links.169941/'}">Some Thread</a>


Just load the thread in the browser and copy everything from the URL from threads on:
View attachment 210965
Thank you! We were originally concerned that any changes in the thread title would make it so this linking style wouldn't work, but it seems to be perfect.
 
Top Bottom