Created
June 22, 2014 09:45
-
-
Save mr-fan/33f9b8690d132beec59f to your computer and use it in GitHub Desktop.
Individual CSS and JS for Processwire trick from Ryan
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<!-- all your typical <head> stuff --> | |
<?php | |
$file = "styles/$page->template.css"; | |
if(is_file($config->paths->templates . $file)) { | |
echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}$file' />"; | |
} | |
$file = "scripts/$page->template.js"; | |
if(is_file($config->paths->templates . $file)) { | |
echo "<script src='{$config->urls->templates}$file'></script>"; | |
} | |
?> | |
</head> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using this method, if you have a template named 'product', then it could have dedicated CSS and JS files in /site/templates/styles/product.css and /site/templates/scripts/product.js, when you need it. The nice thing about this is that it's just a system rather than hard coded file. If you determine you need something unique for the CSS (or JS) on pages using some template, the you can just create the CSS (or JS) file and have it start working automatically.