Provides css hooks to add to your template BODY element, generated from user state and current page meta information.
Applies an extension to
SiteTree that provides css hooks for your template, based on user state (logged in/out/etc) and current page meta information (class, class hierarchy, url-segment/route).
Intended as a cheap and easy method of adding sometimes-useful css hooks to your
Two variables are made available to templates:
FWIW, the classes generated are based on an aged version of my own blend of BEM ... so, there's that. I'm definitely open to standardising them at some point, or allowing them to be set via static config (somehow?) at some stage.
composer require fromholdio/silverstripe-csshelpers
$BodyCSSID is generated using the prefix
page- and the full url-segment of the current page (i.e. it includes the route hierarchy / urlsegment's of parent pages too).
Sample $BodyCSSID: "page-blog-article-name"
$BodyCSSClass is generated using:
Bodyis added as initial part of return string
Body--<urlsegment>for each (allowing css-targeting of specific area of site)
class-<classname>for each, stopping at
Sample $BodyCSSClass: "Body Body--blog Body--blog--article-name class-blogpost class-page action-index logged-out"
Yep. Sometimes this kind of targeting with CSS hooks based on URL segments that the user can update in the CMS on a whim (through your fault or theirs ð), is a hideous and terrible mistake.
But sometimes it's just the right tool for the job in front of you.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem