PDA

View Full Version : Plugin based on user's screen size?


RedTurtle
04-14-2013, 03:42 PM
Hi everyone,

I saw this thread here: https://vborg.vbsupport.ru/showthread.php?p=2415381

and am trying to do something similar. I would like to be able to have certain code run only when a user's screen width is larger than a certain amount.

On my site I currently have a plugin that hooks into global_setup_complete and determines when to show a second advertisement on my forum to a guest visitor. Currently it is setup to only show a second advert if the user is not using a tablet or a phone to view the page. I would also like to add the check for screen width at the plugin level.

I have the following code:

global $vbulletin, $show;
//If the user isn't using a phone or tablet to view the site, show the second advertisement.
if (!$vbulletin->detect->isMobile() AND !$vbulletin->detect->isTablet() ){
$show['second_header_ad'] = true;
}

How can I modify this to also check screen width?

In the thread I linked above, they are using the following code in a template. How can I modify that to work inside my plugin code?

<vb:if condition="screen.width <= 1280">

Code if screen width is smaller than 1280

<vb:else/>

Code if screen width is bigger than 1280

</vb:if>

Thank you so much! :D