Editing Existing Mercury Reader Theme Files

Category
Drupal Version
Tags

This page documents how to customize your Mercury feeds using changes to your local theming files, which are identified by the file-type ".tpl.php".  Both full item pages (/hg/item/item-ID) and feed lists in blocks and pages can be custom themed.

To override the templates listed below, make a duplicate of the desired template in your local theme directory (usually located at sites/all/themes/YOURTHEME/templates), and modify as you see fit. Template-specific documentation is included in the templates themselves. Be sure to convert underscores to hyphens in your templates (use hg-feed.tpl.php instead of hg_feed.tpl.php.)

There are three templates included in Mercury Reader:

  1. hg_feed.tpl.php - Controls the appearance of a feed
  2. hg_item.tpl.php - Controls the appearance of full item displays
  3. hg_media.tpl.php - Controls the appearance of the related media box shown on item pages.

Custom Theming Examples

Removing Images From All News Lists

You could copy the hg_feed.tpl.php file to your theme's templates directory, and then alter the markup so that no thumbnail images are included in a list of news. This would change all lists of news in every Mercury block, or Mercury node on your site.

Removing Images From a Specific List of News

To do this, you'll need to first create a template file that corresponds to a class provided in the "Feed Classes" field that you added to your Mercury block, or Mercury node. For example, if you added the class "newslist," you'd need to copy the hg_feed.tpl.php file to your theme's templates folder, and then rename it hg-feed--newslist.tpl.php (note the use of hyphens instead of underscores in the template file.) You could then alter the hg-feed--newslist.tpl.php file to suit your needs, and any Mercury block or Mercury node that has the "newslist" class listed in its Feed Classes field will display its content based on the markup of the hg-feed--newslist.tpl.php file.

Note: currently if you want to have a multi-word class in your Feed Classes list you'll need to use underscores instead of hyphens for the class, but be sure to stick with hyphens for the template file. This will be fixed in a future update to the Mercury Reader module.

Restyling Mercury Feeds and Content With Only CSS

If you don't want to mess with template files you can also just make use of the "Feed Classes" field to add CSS classes that will apply to a particular Mercury block or node, and then add your desired styling based on those classes to your subtheme's style sheets. All of the classes you add via the Feed Classes field will be output in the outer wrapper <div> of a Mercury feed, or item. For example, if you added "newslist" to the Feed Classes for a Mercury block, the outer <div> of that block would look like:

<div class="hg-feed-wrapper newslist">