XF 2.2 Moving the post_thread button in forum_view

Mr Lucky

Well-known member
In forum_view template I wish to move the post thread button to replace the page navigation. This should be easy shouldn't it?

post_thread.webp

The code for the button is

Rich (BB code):
<xf:pageaction if="$forum.canCreateThread() OR $forum.canCreateThreadPreReg()">
    <xf:button href="{{ link('forums/post-thread', $forum) }}" class="button--cta" icon="write" rel="nofollow">
        {{ phrase('post_thread') }}
    </xf:button>
</xf:pageaction>

And I remove the pagenav and move button to the same position as the pagenav was

Rich (BB code):
<div class="block-outer"><xf:trim>
<xf:pageaction if="$forum.canCreateThread() OR $forum.canCreateThreadPreReg()">
    <xf:button href="{{ link('forums/post-thread', $forum) }}" class="button--cta" icon="write" rel="nofollow">
        {{ phrase('post_thread') }}
    </xf:button>
</xf:pageaction>

But it only works if I remove the page action (shown in red), so then I do get what I want:


Screenshot 2024-07-14 at 11.00.54.webp

BUT

If I don't remove page action the button just shows in its original position.

The problem is if I just move the button code it obviously no longer respects the permissions applied by the page action.

If I put the button code inside a conditional e.g. <xf:if is="{{$xf.visitor.isMemberOf(8)}}”> to reapply permissions via usergroup I get an error.

Line 55: Syntax error - Template name: public:forum_view

Does anyone please know how to solve this, thanks.
 
Solution
the closing quote... is not "
Good point! However I discovered what is probably the correct way, so instead of

<xf:pageaction if="$forum.canCreateThread() OR $forum.canCreateThreadPreReg()">

I just change that to if

<xf:if is="$xf.visitor.canCreateThread() OR $xf.visitor.canCreateThreadPreReg()">
the closing quote... is not "
Good point! However I discovered what is probably the correct way, so instead of

<xf:pageaction if="$forum.canCreateThread() OR $forum.canCreateThreadPreReg()">

I just change that to if

<xf:if is="$xf.visitor.canCreateThread() OR $xf.visitor.canCreateThreadPreReg()">
 
Last edited:
Solution
Cool, but why do you remove the pagenav? It is useful at this position.
Well it's mostly an experiment at this point. I'm making a very simple style and cutting out a lot of unnecessary distraction for a very specific forum. I don't think it would be used for this set of users plus it's still at the bottom where arguably it is possibly more useful.

Besides if it was that important xenForo would not have remove the top one from the small mobile view.
 
Back
Top Bottom