XF 2.3 Using Thread ID in message_macro

SH0CKER

Member
I'm trying to pull the current thread ID for a thread to use to create a link in the message_macro template so that the user can click the generated link to see all of their posts in that thread. This is what I was using, which works... but only if you are looking at the newest thread. I've figured out that $__globals.forum.last_thread_id isn't the variable that I needed since it points to another thread. Any ideas?

Code:
<a href="{{ link('search/search', null, {'c[users]': $user.username, 'search_type': 'post', 'c[thread]': $__globals.forum.last_thread_id}) }}" rel="nofollow">

Thanks!
 
Pass it to the macro template in an arg, then call the arg variable in the template.

Without putting too much effort into debugging your link code (and going through message_macro), something along these lines should give you an idea of how:

A template (thread_view?):
HTML:
<xf:macro id="macro::child" arg-threadId="{ $__globals.forum.last_thread_id }" />

If in thread_view
HTML:
<xf:macro id="macro::child" arg-threadId="{ $thread.thread_id }" />

message_macros:
HTML:
<xf:macro id="child" arg-threadId="!">
    <a href="{{ link('search/search', null, {'c[users]': $user.username, 'search_type': 'post', 'c[thread]': $threadId) }}" rel="nofollow">
 
Last edited:
I might've misunderstood what you were asking, but if it's called in thread_view, $thread.thread_id for the currently viewed thread.
 
Back
Top Bottom