1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'XenForo Questions and Support' started by william1872, Jan 4, 2014.

  1. william1872

    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 : )
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    I'm not sure what you mean or where the image would be located.

    Can you post a mockup?
     
  3. william1872

    william1872 Member

    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?
     

    Attached Files:

  4. Brogan

    Brogan XenForo Moderator Staff Member

    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>
     
    william1872 likes this.
  5. william1872

    william1872 Member

    Thanks Brogan that's fantastic! :)
     
  6. william1872

    william1872 Member

    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>
     

    Attached Files:

  7. Brogan

    Brogan XenForo Moderator Staff Member

    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}
     
    william1872 likes this.
  8. william1872

    william1872 Member

    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 :)
     

    Attached Files:

  9. russoroni

    russoroni Active Member

    @Brogan is there a way to use this but exclude it from a specific forum?
     
    william1872 likes this.
  10. Brogan

    Brogan XenForo Moderator Staff Member

    Use a forum node id conditional statement.

    <xen:if is="{$forum.node_id} != x">
     
    william1872 and russoroni like this.
  11. russoroni

    russoroni Active Member

    Thank you.
     
    william1872 likes this.
  12. william1872

    william1872 Member

    Very cool Brogan this was on my list of things to ask :)
     
  13. russoroni

    russoroni Active Member

    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>
    
     
    william1872 likes this.
  14. william1872

    william1872 Member

    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.png
     
  15. Mike

    Mike XenForo Developer Staff Member

    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.
     
  16. william1872

    william1872 Member

    Ah gotcha, that makes sense....I'll get the developer to stop tweaking and start looking for another solution
     

Share This Page