madeyourday / contao-rocksolid-custom-elements

RockSolid Custom Elements Contao Extension
http://rocksolidthemes.com/de/contao/plugins/custom-content-elements
MIT License
48 stars 12 forks source link

get css body inside rsce_ template #53

Closed rocchidavide closed 9 years ago

rocchidavide commented 9 years ago

Is it possible to get the css of the body tag from inside an rsce_ template? I made with rsce the header of a website and I would like to change header appareance (dark or light) for every page by setting a class in the body field. The idea is to avoid Contao layout duplication for only a header class to set. Oh, obviously any other smarter idea is welcome :) Thank you

ausi commented 9 years ago

You can print the class of the page with <?php echo $GLOBALS['objPage']->cssClass ?> in a template.

But you could solve it also with CSS only. Assuming a body class dark-version and the header class page-header you could write something like this:

.page-header {
    color: black;
    background: white;
}
.dark-version .page-header {
    color: white;
    background: black;
}

Please note that your question isn’t related to the Custom Elements extension.

rocchidavide commented 9 years ago

I knew the css inheritance method, but i'm mounting a bought theme, so I'm trying to use only the source styles. Ah, Custom Elements is so useful and flexible to do the job ;)

Thank you very much ausi, and sorry for the low relevancy of my question.