XF 2.0 How to add Post Thread button on thread pages?

Chromaniac

Well-known member
I was using a template modification on XF1.x. Looking for a similar code for XF2. Thanks!

Sigh. Just realized this should be in customization section. Sorry.
 
Solution
Hello,

In your thread_view template, find :
HTML:
                    <xf:if is="$thread.canWatch()">
                        <xf:button href="{{ link('threads/watch', $thread) }}" class="button--link"
                            data-xf-click="switch-overlay"
                            data-sk-watch="{{ phrase('watch') }}"
                            data-sk-unwatch="{{ phrase('unwatch') }}">
                            <xf:if is="{$thread.Watch.{$xf.visitor.user_id}}">
                                {{ phrase('unwatch') }}
                            <xf:else />
                                {{ phrase('watch') }}
                            </xf:if>
                        </xf:button>
                    </xf:if>

Add this...
Hello,

In your thread_view template, find :
HTML:
                    <xf:if is="$thread.canWatch()">
                        <xf:button href="{{ link('threads/watch', $thread) }}" class="button--link"
                            data-xf-click="switch-overlay"
                            data-sk-watch="{{ phrase('watch') }}"
                            data-sk-unwatch="{{ phrase('unwatch') }}">
                            <xf:if is="{$thread.Watch.{$xf.visitor.user_id}}">
                                {{ phrase('unwatch') }}
                            <xf:else />
                                {{ phrase('watch') }}
                            </xf:if>
                        </xf:button>
                    </xf:if>

Add this after :
HTML:
                    <xf:if is="$thread.canReply()">
                        <xf:button href="{{ link('forums/create-thread', $forum) }}" class="button--link" icon="write">{{ phrase('post_thread') }}</xf:button>
                    </xf:if>

Screen :
192067

Regards, SyTry
 
Solution
Updated code for XF 2.1 incase anyone looking for it, uses $forum.canCreateThread() check instead of $thread.canReply() and forums/post-thread link instead of old forums/create-thread.

Replace SyTry's provided code with below:
HTML:
                    <xf:if is="$forum.canCreateThread()">
                        <xf:button href="{{ link('forums/post-thread', $forum) }}" class="button--link" icon="write">{{ phrase('post_thread') }}</xf:button>
                    </xf:if>
Hit save and you are good to go.
 
Back
Top Bottom