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

Looking for Ad plugin

Chris D

XenForo developer
Staff member
#3
Depends exactly what you want.

XenForo is pre-loaded with a load of special templates (all prefixed with ad_ ) which are blank, and will enable you to edit and paste your ad-provider's code in.
 
#4
Chris I didn't know that I found it so would I just add the code in the template ? I'm just not sure how to go about this
 

Chris D

XenForo developer
Staff member
#5
Yeah exactly right, but there's lots of these ad_ templates.

ad_templates.PNG

You can use any that you like, and each one represents a different position on your forum.

If you were using Google Ads for example, you'd get some code from them and paste it anywhere in your ad_above_top_breadcrumb template. That would appear here for example:

ad_top_breadcrumb.PNG
 

craigiri

Well-known member
#6
Yes, you can add code in various places in those templates.

In general, you do want to put a div around it.....

Code:
<div style="text-align: center;">
</div>
You can also use various IF statements to show X ad in X forum, etc.

A very simple ad rotation add-on is here:
http://xenforo.com/community/resources/bd-rotating-ads.292/

Or, you can use just about any external script. I use an ancient perl script which then inserts ads depending on the forum node.
 

snoopy5

Well-known member
#7
If I just insert the Google adsense code (javascript) in the ad_xxxx template, how can I make sure that only specific usergroups will see/ not see this ad?

Code:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-1234567";
/* blabla */
google_ad_slot = "1311156088";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
 

Chris D

XenForo developer
Staff member
#8
To specify usergroups that WILL see the ad:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3">
	YOUR AD CODE
</xen:if>
Where 1, 2 and 3 are usergroups that will see the ad.

To specify usergroups that WON'T see the ad:

Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 1, 2, 3">
	YOUR AD CODE
</xen:if>
Where 1, 2 and 3 are usergroups that will not see the ad.

(Notice the ! before the {xen:helper tag... ! always means NOT basically... So if you were reading that in English it would read IF IS NOT MEMBER OF 1, 2, 3 :))
 

snoopy5

Well-known member
#9
To specify usergroups that WILL see the ad:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3">
YOUR AD CODE
</xen:if>
Where 1, 2 and 3 are usergroups that will see the ad.

To specify usergroups that WON'T see the ad:

Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 1, 2, 3">
YOUR AD CODE
</xen:if>
Where 1, 2 and 3 are usergroups that will not see the ad.

(Notice the ! before the {xen:helper tag... ! always means NOT basically... So if you were reading that in English it would read IF IS NOT MEMBER OF 1, 2, 3 :))

Hi

when I insert this code and try to save it in ACP, I get a template syntax error in this line:

Code:
[code]<xen:if is="!{xen:helper ismemberof, $visitor, 1, 2, 3">

If I use the other code, same error, also in line 1.

The whole code looks like this in that specific ad_template:

Code:
<xen:hook name="ad_above_top_breadcrumb" />
<xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-1234567";
/* blablaCI nach x Beiträgen quer */
google_ad_slot = "1311156088";
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>
 

Chris D

XenForo developer
Staff member
#10
Hi

when I insert this code and try to save it in ACP, I get a template syntax error in this line:

Code:
[code]<xen:if is="!{xen:helper ismemberof, $visitor, 1, 2, 3">

If I use the other code, same error, also in line 1.

The whole code looks like this in that specific ad_template:

Code:
<xen:hook name="ad_above_top_breadcrumb" />
<xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-1234567";
/* blablaCI nach x Beiträgen quer */
google_ad_slot = "1311156088";
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>
I missed a curly bracket :mad:

Code:
<xen:hook name="ad_above_top_breadcrumb" />
<xen:if is="{xen:helper ismemberof, $visitor, 1, 2, 3}">
<script type="text/javascript"><!--
google_ad_client = "ca-pub-1234567";
/* blablaCI nach x Beiträgen quer */
google_ad_slot = "1311156088";
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>
That will work now.
 

snoopy5

Well-known member
#11
Thank you very much!

The second code works (exclude groups). The first one not . I think because all users that have a premium group additionally, are at the same time part of the registered usergroup. So a default show them the ad will probbalby not work. But the second code works peferctly. Thanks again.
 

snoopy5

Well-known member
#12
Hi

is in XF an internal limit how many ads can be shown on one page? It seems to me, that XF shows never more than 3 ads at the same time. I only use Google adsense. Or am I not allowed to use 3x the same google code for the same kind of banner?
 

Chris D

XenForo developer
Staff member
#13
There is no XenForo imposed limits. I would imagine this to be a Google Adsense configuration but I'm not entirely sure - not heard of any limits there either.