Target your css

A little known but very powerful feature of Backlight is the classes that are added to each page’s body tag. These classes include page type,  page ID and identifier, page template ID and identifier, slug and more.

You can leverage these classes to target your custom css so that it only applies to, say, all albums. Or all albums using a specific template. Or, by using the slug class, you can target just one specific page.

For example, on my site I use one page as an index page for a series of lessons. These lessons are posted as albums and the index page is using a very customized version of the Descriptive album set layout. Since I also use the Descriptive layout for my regular albums, I wanted this index page to be uniquely targeted.
I wanted to create a “text index” that I could use again if needed. So I made an album set template and used “text-index” as its identifier.

The way to specifically target a page or template is to use a specific class from the body tag. First view the page’s source code and look for the <body> tag. Inside of the body tag you’ll see classes. Here are the classes in the body tag for the above mentioned indexing page:

<body class="pangolin type-album-set template-id-78 template-identifier-main album-set-template-id-66 album-set-template-identifier-text-index slug-back-to-basics cart-unready crg-unready" data-layout="1col right">

As you can see, there is a class in the body tag named “album-set-template-identifier-text-index.” I could have also used “album-set-template-id-66.” I prefer using the identifier because it makes more sense than using an id number.

In your custom css, precede any custom css you’re writing with the needed body class.

As just one example of this, in this text-only index, I wanted to remove thumbnails. The css for that is:

#albums img {
	display: none;
}

But that would remove the thumbnails from all album sets. Not what I want. But if I precede #albums img selector with the body class that’s specific to the album set template, then only album sets using that template will have the thumbnails removed.

Here’s the css I used to remove the thumbnail image from the Descriptive layout for just that template:

.album-set-template-identifier-text-index #albums img {
	display: none;
}

You can see the index page here.

If you have just one page you want to target, look for the “slug” class in the body tag. For the example here, that would have been .slug-back-to-basics.

Using body classes, you can very specifically target all sorts of pages or templates throughout your Backlight site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About this site

This site is: a repository of time-savers and best practices from a user's perspective, picked up from several years of using TTG plugins.
This site is not: a support site.
Read more here.

Subscribe to new posts

Tip Jar

If this site has saved you some time, kept your hair attached, or otherwise prevented you from tossing the mouse through the monitor, feel free to donate.

Categories


Highly recommended. This is my go-to Lightroom book. Click on the book image. (affiliate link)

Affiliate link!

Current TTG versions

Backlight  4 & 5

See the Backlight Modules page on your site for latest Backlight and module versions and changelogs.

You’ll also find the latest version number and download link for the Lightroom Publisher plugin.
(BL 3 and later)

 

Backlight 1 Versions

Backlight 1.2.4
Pages module 1.2.4
Cart Add-on 4.1.7
Client Response Add-on 7.1.3
Theater Add-on 1.2.6
Galleria Add-on 1.0.0
WordPress Add-on 1.2.6
Publisher 3.2.3

Backlight 1 has seen its end of life. See this post.

CE4 Versions

note: CE4 is no longer being developed or sold. See this post.

TTG-BE: 2.0.5a
Autoindex: 7.0.8
Cart: 3.1.4a
CRG: 6.1.3a
Gallery: 6.1.10
Pages: 7.0.15
Publisher: 2.3.3
Stage: 6.1.6
Theme for WordPress: 3.1.2