Jump to content

Template logic for mobile devices


Recommended Posts

Thank you for the reply!  I appreciate you jumping in with ideas!  🙂

I had thought to use that, but my problem was that I'm trying to display some ad code....  

<div class='ipsResponsive_showDesktop ipsResponsive_showTablet'> **ADCODE FOR DESKTOP** </div>

<div class='ipsResponsive_showMobile'> **ADCODE FOR MOBILE** </div>

Will this cause the code to be actually loaded twice (meaning the ad network will actually send two different ads but only one would display to the actual user which would skew conversions?

I thought about trying to figure out something in javascript to look at the browser width and say if less than 425px, write mobile code.  If bigger than 425 write desktop code.  

Edited by Randy Calvert
Link to comment
Share on other sites

I don't think that will cause issues. I do the same for my mobile ads. Google will not load ads in containers that are hidden.

{{$guestAdvert = \IPS\core\Advertisement::loadByLocation( "index_970x250" );}}
{{if $guestAdvert !== NULL}}
    <div class="ipsResponsive_showDesktop">
        {$guestAdvert|raw}
    </div>
{{endif}}
{{$guestAdvertMob = \IPS\core\Advertisement::loadByLocation( "index_970x250_mobile" );}}
{{if $guestAdvertMob !== NULL}}
	<div class="ipsResponsive_hideDesktop">
		{$guestAdvertMob|raw}
	</div>
{{endif}}

 

Edited by Martin A.
Link to comment
Share on other sites

That works.  I wrapped code in the correct div tags and they appear to be working.  I just wanted to make sure I was not causing more problems for me down the line by loading ads but not displaying them.  

Thank you very much!  🙂 

Edited by Randy Calvert
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...