Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2019-12-08 18:27:10

richam
Member
From: Preveza, Greece
Registered: 2013-01-06
Posts: 143
Website

Invoke css by album

Suppose you prefer a minor style modification to a particular album, but don't want to establish a separate page template just to call a different css file.  How would you go about it?  E.G. suppose I have 20 albums but want a purple background on just one.  Is is possible to set up a if-then-else statement based on the name of the album slug, within the css or with a separate php function?  Maybe there's an easier way?

Offline

#2 2019-12-08 20:09:23

Ben
Moderator
From: Melbourne, Australia
Registered: 2012-09-29
Posts: 4,399

Re: Invoke css by album

Hi Mike, there are a number of classes added to the <body> tag that can be used by CSS to target specific albums and templates.  For example, on your album at http://www.michaelrichardsphotography.c … y/c-olden/ there are these classes (amongst others): 
template-identifier-Bez-Tray
album-template-id-143
slug-c-olden

The first two can be used to target all galleries with a given template (one using the identifier, and the other the unique ID that Backlight uses).  The last can be used to target just galleries with the slug c-olden.  That will apply to any galleries with that slug.  It doesn't look like we provide a class that targets a specific gallery, but the chances are that the slug is unique across your galleries.

Offline

#3 2019-12-09 14:21:05

richam
Member
From: Preveza, Greece
Registered: 2013-01-06
Posts: 143
Website

Re: Invoke css by album

Ben, appreciate the info, but need to know the rest of the story.  Can a if-then statement be set up in css?  Or should it be in php?  If the latter, could it change a css parameter directly? Or should it just change to an alternate css file?  For a specific example, I would like to increase the paddding on my Links page so that it's more centered.  And it's the only page or album that I want changed, and don't want an alternate page template.  How would I set it up?
http://michaelrichardsphotography.com/links/

Offline

#4 2019-12-09 14:49:32

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Invoke css by album

You don’t need an if-then
Just use the body class to limit the css to that page.
Let’s say the slug for the Links page is “links.”
One of the body classes will be “slug-links”
Write the css starting with the body class:

.slug-links .selector....…{
     padding: 12px;
}

That css will only work on the Links page.
Just look at the page’s source code for the <body> tag. You’ll see all the classes you can use to make css specific to that page, album, album sent, or template.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#5 2019-12-10 00:19:34

richam
Member
From: Preveza, Greece
Registered: 2013-01-06
Posts: 143
Website

Re: Invoke css by album

Ben, Rod, thanks again.  I got the desired result by using content width rather than padding:

.slug-links div.content.content_width {
     max-width: 1000px;
}

Now armed and dangerous with css.  Have to be careful.

Offline

Board footer

Powered by FluxBB