XF 1.2 Appending an image to the end of new threads?

william1872

Member
Hi all,

I'm not sure if this is possible or not?

I was looking to append an image to the end of content when a new thread is created, it would be a small call to action graphic to encourage visitors to signup once they've read a post.

Ideally would love to retrospectively append that to all existing posts on the forum?

Thanks in advance for any advice : )
 
Sure thing : )

I've highlighted the area in red Brogan, wondering if it's possible to append an image to the end of content when a new thread is created, only to the primary post?
 

Attachments

  • cta example bottom content.webp
    cta example bottom content.webp
    39 KB · Views: 24
Ah, that should be simple enough.

Use the ad_message_body template and a conditional statement for the first post:
Code:
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
Image code here
</xen:if>
 
Hi Brogan,

Almost there a couple of things (This is down to my lack of coding knowledge)

  • The image is being placed at the very top of the thread vs bottom of the content
  • The image is aligned left, how can I align the image center?
Here's the code I'm using, any help very much appreciated and I've attached a screen shot

Code:
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
<a href="http://www.jvfocus.com/join" target="_blank">
<img src="http://www.jvfocus.com/wmimages/400x96_jvfocus_CTA.png" width="400" height="96" border=1></a>
</xen:if>
 

Attachments

  • xenforo support cta image.webp
    xenforo support cta image.webp
    91.4 KB · Views: 20
The problem is the ad template is above the post content in the message template.

The easiest option is to use the ad_message_below template with this code:
Code:
<xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
    <div style="text-align: center">
        <a href="http://www.jvfocus.com/join" target="_blank">
        <img src="http://www.jvfocus.com/wmimages/400x96_jvfocus_CTA.png" width="400" height="96" border=1></a>
    </div>
</xen:if>

Otherwise you can edit the message template and switch the position of these two lines of code:
Code:
<xen:include template="ad_message_body" />
{xen:raw $message.messageHtml}
 
Brogan,

I want to thank you for your help, I really appreciate you taking the time to guide me and code a solution!

The latter works a treat, thanks again :)
 

Attachments

  • xenforo support cta below message.webp
    xenforo support cta below message.webp
    31.3 KB · Views: 19
Ok so I just thought I'd share what I got on this. Here's my code for 'ad_message_below' that shows a banner image at the very bottom of the first post in a thread but doesn't show it in conversations and excludes it from forum ID 6 and 12

Code:
<xen:hook name="ad_message_below" />


<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id} AND {$forum.node_id} != 12 AND {$forum.node_id} != 6">
<center><a href="http://mytopo.com"><img src="styles/uix/xenforo/mytopobanner.png" width="75%"></a></center>
</xen:if>
 
Thought I would followup on this one, we've been trying to get an email lead capture form working at the bottom of threads, however the following error is generated when we submit the form.

"JV Focus - Error
Security error occurred. Please press back, refresh the page, and try again."

Code:
<form accept-charset="utf-8" action="https://app.getresponse.com/add_contact_webform.html?u=Bt1t"  method="post">
<input class="wf-input wf-req wf-valid__email" type="text" placeholder="Email Address">
<input class="submit" type="submit" />
<input type="hidden" name="webform_id" value="675716" />
</form>

On submission the form should direct to a 'confirm subscription page, however the error above is produced instead.

Here's a screenshot of the email form. the main purpose of the form is to capture leads for our site, and put them onto a value followup sequence with the scope of converting them into paying customers, so it's quite an important element to add to the site.

Any advice appreciated?

Lead Capture Form Example.webp
 
The posts themselves are already wrapped in a form (it's used for inline moderation). Unfortunately, you can't nest a form tag inside another form. You might be able to do a workaround with JavaScript or an iframe, but those are the only workarounds I can think of.
 
Top Bottom