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

Avoid Displaying Ads On XF Error Page, Content Template Is Empty

Discussion in 'Troubleshooting and Problems' started by TheBigK, Mar 14, 2013.

  1. TheBigK

    TheBigK Well-Known Member

    I'm using following conditional to control advertisements -

    <xen:if is="{$contentTemplate} != 'member_view' && {$contentTemplate} != 'register_form'">
    I however want to avoid displaying advertisement when XF shows an error page. One of our members avoids displaying profile to guests and when a guest lands on this member's profile page, advertisement and message - This member limits who may view their full profile. appears.

    I thought of adding a rule to avoid displaying ad on the error pages of XF. So I checked for the

    <div id="content" class="">

    The class is empty. What do I enter to avoid display ads on any of XF error pages?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> error

    Add this code to the top:

    <xen:container var="$errorFlag">1</xen:container>
    Now you can check {$errorFlag} in the container scope:

    <xen:if is="!{$errorFlag}">
  3. TheBigK

    TheBigK Well-Known Member

    I used this -

    <xen:if is="{$contentTemplate} != 'member_view' && {$contentTemplate} != 'register_form' && !{$errorFlag}">
    and it seems to be working fine :) . Thanks!
  4. Bram

    Bram Well-Known Member

    My following code works fine but I am probably doing it all wrong. How do I simplify the current code i use for the Ad_Above_Content template :)

    <xen:if is="!{$visitor.user_id}">
    <xen:if is="{$contentTemplate} != 'search_form_post'">
    <xen:if is="{$contentTemplate} != 'search_results'">
    <xen:if is="{$contentTemplate} != 'dark_taigachat_full'">
    <xen:if is="{$contentTemplate} != 'register_form'">
    <xen:if is="{$contentTemplate} != 'login'">
    <xen:if is="{$contentTemplate} != 'error_with_login'">
    <xen:if is="!{$errorFlag}">
    <div style="text-align: center;">



    One tip to all: make sure you NEVER display ads on the search results pages as Google TOS doesnt allow it. @XenForo: can this be "fixed" in the next 1.2 version?
  5. James

    James Well-Known Member

    @Bram instead of using so many if statements on the contenttemplate variable, why not use one conditional checking in_array and put the relevant templates into the parameters.
  6. Brogan

    Brogan XenForo Moderator Staff Member

    An example of what James suggested (from my own site):

    <xen:if is="!in_array({$contentTemplate}, array('register_form', 'forum_list', 'cta_overtaking_index'))">
    Jake Bunce likes this.
  7. RoldanLT

    RoldanLT Well-Known Member

    Does displaying adsense ads on error page/like private profiles/thread not found/forum not found is also not permitted by google?
  8. DVDPlaza

    DVDPlaza Member

    This is a reply to 2 year old post but... that above is incorrect - you can put Adsense on your own search page (ie. when you are not using Google's search results). See here -> AdSense for search policies - AdSense Help

    Can I display ads on non-Google search results pages?
    If you have non-Google search results pages on your site, you're welcome to place Google ads on them.

Share This Page