XF 2.3 Trying to show a message to the thread starter...

cjwinternet

Active member
Hi. I'm trying to display a message for the thread starter, prompting them to share the post to facebook.

I've tried posting it as a Notice, that doesn't work.
I've created a template for the text "Share_to_FB_for_OP"

So I tried inserting the following code directly into the thread_view template...

Code:
 <xf:if is="{$visitor.user_id} == {$thread.user_id}" && "{$post.position} == 0" && "in_array({$forum.node_id}, [1, 3, 5])" &&  "$xf.visitor.is_admin">
           <xf:message template="Share_to_FB_for_OP" />
       </xf:if>

I would have thought that this would calculate when the visitor was the thread starter, whether the thread was started in forums 1,3, or 5, and for testing, whether that user was an admin.

However I get the following message "Line 85: Syntax error - Template name: public:thread_view"

1752778747527.webp

1752778721069.webp

Any help would be appreciated, thanks.
 

Attachments

  • 1752778565220.webp
    1752778565220.webp
    13.4 KB · Views: 0
This is the correct syntax.

HTML:
<xf:if is="{$post.user_id} == {$thread.user_id} && {$post.position} == 0 && in_array({$forum.node_id}, [1, 3, 5]) &&  $xf.visitor.is_admin">
    <xf:include template="template_name" />
</xf:if>

As far as $xf.visitor.is_admin though - not really sure what that is supposed to be doing.

If you just want to display the message to the thread starter, omit that.

You will also need to confirm all of the vars are present in the template you are adding them to.
 
I read that, and it's got all the vars. I'm using unmodified default theme, and the following code...

Code:
<xf:if is="{$post.user_id} == {$thread.user_id} && {$post.position} == 0">
                 <xf:include template="Share_to_FB_for_OP" />
</xf:if>
 
Back
Top Bottom