[Resolved] How to display a different View on mobile devices?
This thread is resolved. Here is a description of the problem and solution.
Problem:
Client wants to display a different View on mobile devices.
Solution:
WordPress contains a built-in function wp_ismobile() that can be used in conditional shortcodes to determine which View is inserted depending on the device.
This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am using Toolset views to create a gallery of images that link to individual entries.
I have set up 3 separate views for each gallery so that I can display a different amount of images depending on the device.
15 for desktop
12 for tablet
9 for mobile
I then use css to hide or show the appropriate gallery in the front end.
My question is... is my site generating all 3 views every time the user browses to a page? If so that seems like a very inefficient way to do things as my server needs to work 3 times as hard and takes 3 times longer to generate the page.
I read several posts where in which it was said that this should not effect page load time - but I don't see how that can be the case as the server needs to make 3 times as many requests etc.
Is this the proper way to handle various screen sizes?
You are right. Simply hiding the alternative galleries with CSS means they are *all* downloaded, making this a much worse solution in performance terms than just including a single gallery for all devices.
You need to make the decision *before* the page is rendered.
So where you insert these Views you can use conditional shortcodes and first check what device information you have to decide whether to display the particular gallery or not.