Chapter 6. Advanced Magento Theming

Now you have seen the basics of creating a custom Magento theme, and you will build on this using the following techniques in this chapter:

  • Adding a custom print style sheet to your Magento store
  • Using locales to translate labels/phrases in your store
  • Using @font-face in Magento
  • Styling Magento's layered navigation
  • Creating a custom 404 "not found" error page
  • Using microformats for rich snippets to enhance search engine listings

Adding a custom print style sheet to your Magento store

So far, you've styled your Magento store for electronic screens, but what about for those customers who want to print product pages? Even in this digital age, some customers like to print details of a product and review them offline.

You can specify a separate CSS file in your Magento theme to be applied when your documents are printed. By default, Magento inherits the print.css file in the /skin/frontend/default/default/css/ directory, which provides some basic styling for printed documents, such as removing navigation and the store's footer, as shown in the following screenshot:

Adding a custom print style sheet to your Magento store

As you can see, there is still some work to be done here, as the sidebar content (the Facebook box) isn't functional or useful when the page is printed!

Tip

You can view the print version of your Magento theme in most browsers by using the Print preview tool.

You can overwrite the print.css style sheet for your theme by creating a file called print.css in your theme's css directory (for example, /skin/frontend/default/m18/css/), but this will overwrite some of the work that the base print style sheet already does to help style your store's pages better for printing. Instead of overwriting this file, you can add another CSS file to add custom style instructions for printing.

To do this, open your theme's local.xml file (in the /app/design/frontend/default/m18/layout/ directory) and add the highlighted XML instruction within the <default> handle:

<default>
<reference name="head">
  <action method="addCss">
      <name>css/print-custom.css</name>
    <params>media="print"</params>
  </action>   
</reference>
</default>

You can now create a new CSS file called print-custom.css in the /skin/frontend/default/m18/css/ directory and begin to add the print CSS specific to your new Magento theme:

.sidebar {
display: none;
}

If you now refresh the print preview of the page, you will see that the sidebar has been hidden in the following screenshot, and the content printed is much more useful!

Adding a custom print style sheet to your Magento store
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.45.74