To show ads only on the homepage can vary based on how you wish to show them – using an ad manager addon or by modifying the template.
Let me share both the options to show ads only on the homepage.
In either case, we need to know what is the name of the content template name used for the homepage.
How to Find Homepage Content Template Name?
Normally you can set up any page as homepage in XenForo and if you have done that, the content template will change.
If you are on default homepage with a list of forums and sub forums being displayed the template is “forum_list”.
If you have custom home page, the template name can be fetched from the source code of the HTML.
Look for the div with id=”content”. The class name of that div is the name of the content template.
Ideally, for forum_list homepage, it will be
<div id="content" class="forum_list"> |
So content template name is forum_list. If you are using XenPorta 2‘s list of articles as a homepage, the content template name will be “EWRporta2_ArticleList”. On my DIYTechnicalAnalysis forum we have timeline as the homepage and so the content template is from the timeline plugin which is “timeline_wrapper”.
Once we have the name of the content template, we can use either the ad manager or template conditions to show ads only on the homepage.
Using Ad Manager to show ads only on homepage
There are numerous addons for managing ads in XenForo and by far the best and most comprehensive one is Ad Manager By Siropu.
Within the ad manager, look for the “Page Criteria” tab and within the tab look for the “Page Information” section in which you will find the “Content Template is” checkbox.
Enable the checkbox and in the text field enter the homepage template name. In the screenshot above I have entered “forum_list”. The ad will only show on the homepage at the required position and based on the other criteria selected.
Using template code to show ads only on homepage
We have a long list of templates where we can place an ad.
You can select any one of the above templates or can use any custom placement within the PAGE_CONTAINER template. The code will remain the same.
To show the ad only on the home page, use the Xen if conditional code as follows
<xen:if is="{$contentTemplate} == 'forum_list'"> | |
<!-- Ad banner code start --> | |
<!-- Ad banner code end --> | |
</xen:if> |
If your homepage template is different from forum_list, change accordingly.