Jump to content


Photo
* * * * - 2 votes

Ad Slots - Conditions


  • Please log in to reply
4 replies to this topic

#1 BigStamp

BigStamp

    IPB Full Member

  • Members
  • PipPipPip
  • 140 posts

Posted 22 August 2012 - 07:24 PM

I'm currently using Google Dfp for my ad serving, with the asyncronous single call tags.

One thing I found was that if I just added the code to my header it was calling ads slots that were not actually being show on the page.

With Xenforo I've managed to solve this from by doing the following:

<xen:if is="{$visitor.user_id}"><xen:if is="in_array({$contentTemplate}, array('forum_list','online_list','news_feed_page_global','conversation_view','member_list','search_results','search_results_users_only','report_view'))">googletag.defineSlot('/803025/Forum-Header_Small-Members', [468, 60], 'div-gpt-ad-1344102488647-5').addService(googletag.pubads());<xen:else />googletag.defineSlot('/803025/Forum-Header-Members', [728, 90], 'div-gpt-ad-1344102488647-3').addService(googletag.pubads());</xen:if><xen:else /><xen:if is="in_array({$contentTemplate}, array('forum_list','online_list','news_feed_page_global','conversation_view','member_list','search_results','search_results_users_only','report_view'))">googletag.defineSlot('/803025/Forum-Header_Small-Guests', [468, 60], 'div-gpt-ad-1344102488647-4').addService(googletag.pubads());<xen:else />googletag.defineSlot('/803025/Forum-Header-Guests', [728, 90], 'div-gpt-ad-1344102488647-2').addService(googletag.pubads());</xen:if></xen:if>
<xen:if is="{$visitor.user_id}">googletag.defineSlot('/8035025/Forum-Footer-Members', [728, 90], 'div-gpt-ad-1344102488647-1').addService(googletag.pubads());<xen:else />googletag.defineSlot('/8035025/Forum-Footer-Guests', [728, 90], 'div-gpt-ad-1344102488647-0').addService(googletag.pubads());</xen:if>
<xen:if is="{$contentTemplate} == 'member_view'"><xen:if is="{$visitor.user_id}">googletag.defineSlot('/8035025/Forum-Members_Page-Members', [468, 60], 'div-gpt-ad-1344102488647-7').addService(googletag.pubads());<xen:else />googletag.defineSlot('/8035025/Forum-Members_Page-Guests', [468, 60], 'div-gpt-ad-1344102488647-6').addService(googletag.pubads());</xen:if></xen:if>
<xen:if is="{$contentTemplate} == 'thread_view'"><xen:if is="!{$visitor.user_id}">googletag.defineSlot('/8035025/Forum_Post', [728, 90], 'div-gpt-ad-1344102488647-16').addService(googletag.pubads());</xen:if></xen:if>

This allows me to show different ads to members or guests, and also only makes the call for the ad slot if its on the page thats being loaded.

Is this something I can achieve with IPB, I know I can do it for the members/guests as i've seen the code for that. But are there Conditionals that I can wrap the code in depending whether someone is viewing the home page, forum lists or a thread?

Also is there a list of the conditionals that can be used like what's available over on Xenforo? (http://xenforo.com/c...83/#post-182355)

#2 bfarber

bfarber

    RBT-KS

  • IPS Management
  • 27,045 posts

Posted 23 August 2012 - 08:35 AM

http://community.inv...rials/skinning/

This is the general skinning documentation. Looks like you are after this article: http://community.inv...-variables-r155

If you were looking to determine if the user was viewing a topic, you could for instance do

<if test="ipsRegistry::$current_application == 'forums' AND ipsRegistry::$current_module == 'forums' AND ipsRegistry::$current_section == 'topics'">

Brandon Farber
Developer / Senior Support

If it sounds like fun, it's not allowed on the bus!

Posted Image     Posted Image

Invision Power Services, Inc.

#3 BigStamp

BigStamp

    IPB Full Member

  • Members
  • PipPipPip
  • 140 posts

Posted 23 August 2012 - 02:52 PM

Thanks, I've had a read but it looks confusing.

Is this something that would start make sense when I start using IPB?

#4 bfarber

bfarber

    RBT-KS

  • IPS Management
  • 27,045 posts

Posted 23 August 2012 - 03:13 PM

It's just a different syntax/variable.

<xen:if is="{$contentTemplate} == 'thread_view'">

vs

<if test="ipsRegistry::$current_application == 'forums' AND ipsRegistry::$current_module == 'forums' AND ipsRegistry::$current_section == 'topics'">

As you can see, the general syntax is similar. In your first example it's checking a variable that holds the template name. In the example I provided, you are checking which application, module and section is being called. You might also be able to check other variables as well (for instance, if you want to know if someone is viewing a topic, checking if $this->request['showtopic'] is set should work), but I was trying to provide an off-hand example to give you an idea.
Brandon Farber
Developer / Senior Support

If it sounds like fun, it's not allowed on the bus!

Posted Image     Posted Image

Invision Power Services, Inc.

#5 BigStamp

BigStamp

    IPB Full Member

  • Members
  • PipPipPip
  • 140 posts

Posted 23 August 2012 - 03:36 PM

Thanks,

That makes a little more sense.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users