I need to apply dynamic css for each node. I have stored the css into the database for each row of the page.
I have generating css like node_57002-en.css
here, 57002 is a node-id with language code for each responsive layout.
For eg. If I select width for desktop layout for node-id-57002
then node_57002-en.css
generated with below code.
@media only screen and (max-width:991px) {}@media only screen and (max-width:767px){}
I have to find out the better solution becouse, everytime generated the new css for each node. Below is the code which I used,
$styles = $nodeProcessor->getStyles();
$rowCss = $styles->getDesktop() . "@media only screen and (max-width:991px) {" . $styles->getTablet() . "}" . "@media only screen and (max-width:767px) {" . $styles->getMobile() . "}";
$cssPath = $modulePath . '/resources/css/rows/node_' . $this->_nid . '-' . $this->_langCode . ".css";
$cssPath .= '?' . filemtime($cssPath);
I have some questions on this,
How to get that css from db and how to apply on front-page in drupal manner.
How to cache the library css and how to clear the cache when css updated?
If not then what is the alternative option.
I referred Dynamically generated CSS and JS document but it is only for dynamic js. I really appreciate if anybody helps me. Thanks in advance.