Answer the question
In order to leave comments, you need to log in
Inline css embedding files in html, snippet for modx?
Need to implement opening css file and embed its content in html
<head>
<style>[[inline? &file=`assets/css/critical.css`]]</style>
...
Answer the question
In order to leave comments, you need to log in
Embeds files in code
<?php
$assetsPath = $modx->getOption('assets_path');
$file = !empty($file) ? $file : $modx->getOption('file', $scriptProperties, '');
$myfile = fopen($assetsPath . $file, "r");
if (!$myfile){ return "";}
$inlneCSS = "";
while(!feof($myfile)) {
$inlneCSS .= fgets($myfile);
}
fclose($myfile);
return $inlneCSS;
<script>[[inline?&file=`js/modernizer.js`]]</script>
<style>[[inline?&file=`css/critical.css`]]</style>
Good afternoon!
You gave an example not inline css, but internal css with a file connection with styles. In general, you can simply specify the paths to the files. If you really like using separate snippets for this, then here it is: minifyx . This snippet has much more functionality than just including a file with styles.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question