I know you're not bashing it.
Let's see if I can be a bit of help...
Firstly, editing templates.
You are correct to a certain extent. It isn't always recommended to edit templates. But template edits are not lost after upgrades. Changes you make to templates will always be left untouched. If XenForo update that template in an upgrade, the template will be marked as "outdated" but your changes remain active. So, in that case, template edits aren't always a great idea.
This, however, doesn't apply to ad templates.
Ad templates are templates which the XenForo developers have deliberately left blank. As they are blank, they will never be updated by XenForo and therefore they will never become outdated, therefore as long as the template name begins with
ad_ they are completely safe to edit.
You can find a list of ad templates by doing the following:
- Log in to Admin CP
- Click the Appearance navigation tab
- Click Templates in the left menu
- In the "Filter Items" field type: ad_ and click prefix match
These will display all templates that start with ad_. These templates have been specifically reserved for the purpose of ads.
Some may contain a line such as <xen:hook name="ad_message_below" /> just ignore this (but don't delete it) and insert any code you need above or below that line.
The names are usually descriptive of the location.
So it sounds like you want to display an ad in messages. Let's deal with that first.
So if you use Google Ads and the code they give you is as follows (it would look very different to this):
Code:
<br />
<center><img src="https://www.google.com/help/hc/images/adsense_185666_adformat-display_728x90_en.jpg" /></center>
<br />
You would simply paste that code in the ad_message_below template, and et voila, your threads look like this:
Ok... not ideal.
But that's how easy it is. This won't be lost when the forum is upgraded.
That displays the ad after every single post and to all members.
Let's make it so it only displays after the first post...
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0">
<br />
<center><img src="https://www.google.com/help/hc/images/adsense_185666_adformat-display_728x90_en.jpg" /></center>
<br />
</xen:if>
Post position "0" is the first post in the thread. By adding the "messagesPerPage" part, this sets the advert to appear after the first post on each page. You don't necessarily need to understand that in detail, that's just what it does.
If you display 20 posts per page and you want to show the ad after the first post and last post on each page...
Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 OR {$post.position} % {$xenOptions.messagesPerPage} == 19">
<br />
<center><img src="https://www.google.com/help/hc/images/adsense_185666_adformat-display_728x90_en.jpg" /></center>
<br />
</xen:if>
This shows to all users still.
Let's say you want to show the ads to everyone except staff (user groups 3 and 4) and perhaps to a premium/paid usergroup you've created which in this example is user group ID 5:
Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 3, 4, 5}">
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 OR {$post.position} % {$xenOptions.messagesPerPage} == 14">
<br />
<center><img src="https://www.google.com/help/hc/images/adsense_185666_adformat-display_728x90_en.jpg" /></center>
<br />
</xen:if>
</xen:if>
You've now got a very quick and easy method to display adverts in specific locations within threads to specific usergroups.
This might be a lot to take in, but it works. It's a shame to delay this working on your large sites. There's many people who haven't got a clue what any of this means and they make do and make their XenForo sites successful and functional just by simply asking how things could be achieved.
You will always get quick answers here, and if adverts in certain positions, hidden from certain usergroups was your only reason to delay putting this on your larger site then maybe that's problem solved. If not, try it out and feel free to ask more questions. If there's anything you don't understand I will be happy to help.
Chris.