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

HELP: my after 1st post ad template edit broke quick edit

Mutt

Well-known member
#1
I've created a quick edit of the first post error w/ this template edit. Can someone help me correct it? when I save the edited 1st post, the page loads w/ the 1st post completely gone (though the banner is still there) & the little action progress animation running indefinitely.

I'm using this code for ad_message_below to place a banner after the 1st post on every thread page.

Code:
<xen:hook name="ad_message_below" />
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id}">
    <xen:comment>after 1st post</xen:comment>
    <li id="after_1st_post_ad" class="message">
    <div align="center" style="background: white; padding: 10px; margin: 10px auto; border: 1px solid black; border-radius: 10px;">
        <xen:if is="{xen:helper ismemberof, $visitor, 20, 12, 9}">
            SFN Supporters & VIPs don't see this ad.
        <xen:else />
            <xen:if is="{$forum.node_id} == 6">
                this is an adult ad
            <xen:else />
                <script type="text/javascript"><!--
                    google_ad_client = "ca-pub-xxxxxx";
                    /* after 1st post - 728x90 */
                    google_ad_slot = "7074045484";
                    google_ad_width = 728;
                    google_ad_height = 90;
                    //-->
                </script>
                <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
            </xen:if>
        </xen:if>
        <xen:if is="{$visitor.is_admin} AND {$xenOptions.showAdLocations}">
            <div align="center" style="background: yellow; padding: 4px; font-size: 16px; font-weight: bold; width: 500px;">ad_message_below 1st</div>
        </xen:if>
    </div>
    </li>
<xen:else />
    <xen:comment>between posts</xen:comment>
    <xen:if is="{$visitor.is_admin} AND {$xenOptions.showAdLocations}">
        <div align="center" style="background: white; padding: 10px; margin: 10px auto; border: 1px solid black; border-radius: 10px;">
            <div align="center" style="background: yellow; padding: 4px; font-size: 16px; font-weight: bold; width: 500px;">ad_message_below</div>
        </div>
    </xen:if>
</xen:if>
I know there's alot going on there but it's this line causing the issue.
Code:
<li id="after_1st_post_ad" class="message">
 
</li>
I inserted that line to ensure that on short posts the ad was displayed after the post & not sorta in the post area. when i remove it the problem goes away.
 

Brogan

XenForo moderator
Staff member
#2
I noticed a quirk with this a while ago.

If you want to move the advert out of the post, you need to use: </li><li>
However, it must be on the same line like that.

If you do it like this it won't work:
</li>
<li>

Having said that, you're using an opening li before you have closed the existing li related to the post.
 

Mutt

Well-known member
#4
Brogan, that fixed it. there is a little quirk. no biggie & doesn't need to be fixed. I'm just not sure why it's there.

after submitting the edit, it looks like this. it's like the ad got was posted twice. like I said, I can live w/ that quirk. at tleast the page submits right now
Screenshot_1.jpg
 
#5
Hello guys, I have the same problem but for me it didn't work (the Brogan's method). I don't know what to do, help please if you know the answer.

Here is my code:

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
    <li class="message">
 
        <div class="messageUserInfo">
            <div class="messageUserBlock">
                <div class="avatarHolder"><span class="avatar  av2m"><img  src="http://mysite.com/styles/default/xenforo/avatars/avatar_m.png"  width="96px" height="96px"></span></div>
 
           
 
                <span class="arrow"><span></span></span>
            </div>
        </div>
 
      <div class="messageInfo primaryContent">
            <div class="messageContent">
                <blockquote class="messageText ugc baseHtml">
                    <script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxxxxxxx";
/* inside_f */
google_ad_slot = "xxxxxxxxxxx";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
                </blockquote>
            </div>
          </div>
      </li>
</xen:if>
When I insert some text instead of the google adsense code all is OK, but when I'm using any <script> code, I have the same problem Mutt had.

I will appreciate any help.