XF 2.2 Copy to clipboard links in Threadlist items

tomnjerry74

Member
I'm trying to add a "Copy link" text on each item within the thread list and can't get it to work. I've tried various combinations in thread_list_macros of:

Code:
<a data-xf-init="copy-to-clipboard" data-clipboard="{{ link('forums', $thread.Forum) }}">Copy link</a>
<a data-xf-init="copy-to-clipboard" data-clipboard="{$thread.url}">Copy link</a>
<a data-xf-init="copy-to-clipboard" data-copy-text="{{ link('forums', $thread.Forum) }}">Copy link</a>
<a data-xf-init="copy-to-clipboard" data-copy-text="{$thread.url}">Copy link</a>


Any help is very appreciated
 
Untested but you should be able to use this:
HTML:
<a data-xf-init="copy-to-clipboard" data-copy-text="{$xf.fullUri}{{ link('threads', $thread) }}">Copy link</a>

Edit: Actually that's probably not going to work as the URI will be for the forum, not the thread.
 
Last edited:
Untested but you should be able to use this:
HTML:
<a data-xf-init="copy-to-clipboard" data-copy-text="{$xf.fullUri}{{ link('threads', $thread) }}">Copy link</a>

Thank you, it outputs an extra forward slash in the form of "https://mysite.com//threads/thread.100/" but the link still functionally works. Definitely cleaner than putting the site url in the template.

Edit: Oh, maybe it works for me because I have my index routed as the thread list.
 
Last edited:
Back
Top Bottom