These days, most web developers clearly understand the need to optimize a website for use on mobile devices. Usually this includes the implementation of responsive CSS to create a great browsing experience for users of every screen size. However, there are times when changing the layout is not enough. What if you need to go about changing the actual content of a page to work better for mobile visitors? An Example Use Recently, I was faced with this very issue. I’d built a WordPress site for a client using an events registration plugin. Its calendar layout was fantastic on larger screens, but completely unusable on smaller ones. While it seemed easy enough to change some CSS around to make it more mobile-friendly, this turned into quite an adventure. After my attempts at reworking the CSS failed, I decided that it might be more efficient to simply list the upcoming events for mobile users rather than keeping the calendar format. But how? Mobile Detect to the Rescue A little research turned up Mobile Detect, a PHP class that helps detect mobile devices. It uses user-agent strings and looks for specific HTTP headers in order to determine if a user is visiting from a mobile device. Then,
Share This