Tutorials and Guides

03/01/2011 - 6:13pm

You can use multiple external style sheets to serve up the site's existing content to a variety of users.

As an example, this is what the Engineering Library's Ask Us page looks like when it's displayed on a desktop computer or laptop, using the library's "screen media" style sheet (0engi.css):

screen shot of the Engineering Library's Ask Us page, as shown on a computer monitor

This is what the Engineering Library's "Ask Us" page looks like when it's displayed on a mobile phone emulator, using the library's "handheld media" style sheet (0engi_handheld.css). In the image on the left, note that there's a special text-based logo that would be displayed only on handheld devices. The center image shows some page content, with text and an image. The image on the right shows what part of the e-mail form looks like on this style of mobile phone.

three screen captures from a mobile device emulator showing the Engineering Library's Ask Us page

Note: both devices are loading the same web page! The style sheets are controlling how the content is displayed, and each device's web browser chooses which one to use.

03/01/2011 - 6:13pm

While modern mobile devices can display your content quite well, there are some issues that you should keep in mind regarding font and scripting support. In addition, certain content types may not display well on small screens, including large images, nested lists, and tables.

Fonts

Font support can be spotty. In some mobile device browsers, only one font face is supported, with limited font size support. Handheld device browsers can support bold text, but support for italic text may be poor. My advice:

  • Go ahead and style your text as you wish using CSS, but be aware that some of the handheld device browsers may render your text in a limited way.
  • Use percentages or absolute size keywords to specify font sizes rather than pixels. That should help keep the text readable on a small screen.

The seven absolute size keywords are xx-small, x-small, small, medium, large, x-large, and xx-large. You might consider specifying the medium size as the default size for the paragraph element.

Scripts

JavaScript is poorly supported in mobile web browsers, so you should avoid its use or provide an alternative for users who can't use JavaScript or have it turned off. This practice would also help some disabled users as well as handheld device users.

Here's a rather crude example of how to provide an alternative by using <noscript> code:

<script type="text/javascript"> document.write('Hello Javascript World'); </script><noscript>Hello World Without Javascript</noscript>

In this case, the browser would display the message Hello Javascript World if Javascript is supported. Otherwise, Hello World Without Javascript would be displayed.

However, this doesn't mean that all scripts cause problems. For example, the CGI-based scripts that are often used to activate forms usually work as expected on mobile devices, so feel free to keep them in place.

Content Types

In my experience, only three commonly used content types cause serious display problems on handheld devices: large images, nested lists, and tables. Fortunately, there's a way to work around each of these display problems.

Large Images

Since mobile device screens can be very small, the mobile device browsers will attempt to resize large images so that they will fit on the screen. Even though the browser is displaying a small image, the actual file size remains large and the image may load very slowly.

Fortunately, it's easy to use CSS to hide large images to keep them from loading in the mobile environment. There's a very useful attribute and value pair ("display : none") for use within CSS documents that you can put into place to hide content from display on mobile devices (or other hardware, for that matter).

To do this, you can create a custom class to add to your external "handheld media" style sheet, and this custom class can be used whenever you need it:

     .dontShow { display : none; }

Note that the class name begins with a dot (.dontShow). The dot tells the browser that you're creating a custom CSS class and that this class can be used many times within the document.

The "display : none" attribute and value pair coding instructs a mobile device's browser to ignore the content in question and to not display it, while a desktop PC or laptop would still be able to display it.

For example, if you've created a class called .dontShow and you want to hide a large image, add the class to your image element code:

     <img src="images/world_map.gif" class="dontShow" alt="map of the world" />

Coding Tip: Note that the dot in the .dontShow class name is not needed and should not be used within the <img> element.

Design Tip: Small images, such as RSS feed icons or "bookmark this" buttons, can work well in the mobile web environment so feel free to keep them in place. Well-chosen small graphics can be beneficial to users at any screen size.

Nested Lists

Nested lists can get pretty ragged-looking on a small display. Try to keep your lists to only one level of nesting.

You may need to recast your lists — try replacing the outer level of nesting with paragraph XHTML elements instead of list elements.

Tables

Tables do not display well on the smallest mobile devices, so you'll need to avoid using table-based coding to lay out your pages. Use CSS layout techniques instead. If you're not familiar with CSS page layout techniques, I’ll be providing a simple example later in this guide.

If you have a large table containing tabular data, you can hide it from view on mobile devices while making it available for "screen media" users:

     <div class=”dontShow”>

     <table>

     [ table coding goes here ] . . .

     </table>

03/01/2011 - 6:13pm

When your new mobile friendly redesign is ready to go live, it's a good plan to do some online testing first. If you have a handheld device and an account with web access, that will come in handy and you can also use your emulators. You might invite your regular clientele to do some testing with their own devices, and ask them to let you know if they notice any problems or have suggestions for improvements.

Note about the iPhone and iPod touch

If you've got an iPhone and iPod touch and are using the Safari web browser, the screen media external style sheet will be loaded rather than the handheld device style sheet. This particular kind of mobile device won't be as useful for testing purposes.

Setting up your testing environment

Depending on what your working environment is like, you may have two options for doing the initial testing.

  • If you have an online testing area or sandbox, you can install everything there.

  • Create copies of several of your new mobile friendly pages, and install them on your regular website as "testing" pages.

03/01/2011 - 6:12pm

Blocks are nice, but they don't solve all of your site organization problems. The Panels Module solves some of these problems. If you have a UCB Library Drupal site, go to the modules list and turn on the mini-panels, panel nodes and panels. Look at the information given for each of the module settings and make sure you've turned on the other required modules.

To get started with Panels view the tutorial video and the following links. I'm directing you to Panels 2 documentations, even though Panels 3 is the latest version. The Panels 2 site has the most documentation and is applicable to what you'll be doing with Panels 3.

03/01/2011 - 6:12pm

A short video on adding stories to a drupal site.