Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum
https://www.tinywebgallery.com/forum/

TRying to modify short code dynamically
https://www.tinywebgallery.com/forum/viewtopic.php?f=21&t=4525
Page 1 of 1

Author:  tenspd137 [ 30. Jan 2018, 04:34 ]
Post subject:  TRying to modify short code dynamically

I am working on a website for a shelter that uses petango to display an IFrame. My shortcode looks like this:

[advanced_iframe securitykey="xxxxxxxxxxxxxxxxxx" use_shortcode_attributes_only="true" src="http://ws.petango.com/webservices/adoptablesearch/wsLostFoundAnimals.aspx?LostFound=StrayOnly&species=All&gender=A&agegroup=All&colnum=3&orderby=ID&authkey="xxxxxxxxxxxxxxxxx" width="100%" height="600" id="advanced_iframe" enable_responsive_iframe="true" ]

I would like to be able to detect the size of the screen and set the number of columns to 1 or 3 - ie a mobile device with small screen. Mind you I am new to javascript and web programming in general, but I thought something like this in a custom html block would work:

Code:
<script type="text/javascript">
var cols = 0;
   if($(window).width() < 400)
   {
      cols = 1;
   }
   else
   {
      cols = 3;
   }
   
   return ([advanced_iframe securitykey="xxxxxxxxxxxxxxx" use_shortcode_attributes_only="true" src="http://ws.petango.com/webservices/adoptablesearch/wsLostFoundAnimals.aspx?LostFound=StrayOnly&species=All&gender=A&agegroup=All&colnum="+cols.toString()+"&orderby=ID&authkey=xxxxxxxxxxxxxxxxxxxxxxxxx" width="100%" height="600" id="advanced_iframe" enable_responsive_iframe="true" ]);
</script>


but it doesn't. Any idea how I would go about this in WordPress?

Author:  TinyWebGallery [ 31. Jan 2018, 19:26 ]
Post subject:  Re: TRying to modify short code dynamically

This is not working because a shortcode is rendered on the server but Javascript on the client.
This does not work at all together.

You need to do this completely different! The plugin has an integrated browser detection in the pro version!
so you define 2 shortcodes - one for desktop and one for mobile.
check the integrated help for the browser detection.

Best, Michael

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/