I need to add a class to the body tag of each page (wanna give each page a different border color). How would approach that? My header snippet contains the body tag.
What I basically need is something like
<?php e($item->isOpen(), ' class="active-page"') ?>just for pages, right? Can someone point me in the right direction?
Here’s what I use in my header snippet:
<body class="p-<?= $page->parent() ?> p-<?= $page->slug() ?> y-<?= date('Y') ?> m-<?= date('m') ?> h-<?= date('H') ?>">
There are better more efficient ways to do this, but this puts in the parent, the slug, and the year, month and hour for other tricks…, it needs a rework, but this should help.
I wouldn’t rely on the magic
__toString() method here, but explicitly output what you need:
p-<?= $page->parent()->slug() ?>
<body class="<?= $page->slug() ?>-border ">
Did the trick! Embarrassingly simple.
Thank you… !