jarv Posted May 20, 2013 Share Posted May 20, 2013 hi, I am going through this tutorial: http://net.tutsplus.com/tutorials/php/supercharge-your-css-with-php-under-the-hood/ I have done what you said:here is my CSS page: <?php header('Content-type=text/css'); ?> #headcontainer { background-color: #<?php echo $headcontainerbg; ?> } here is my .htaccess (in the CSS folder) AddType application/x-httpd-php .html .htm .css AddHandler application/x-httpd-php .html .htm .css AddHandler application/x-httpd-php5 .css I am importing CSS stylesheet like my others I am using MAMP locally, still nothing Quote Link to comment Share on other sites More sharing options...
requinix Posted May 20, 2013 Share Posted May 20, 2013 header('Content-type=text/css');should be header('Content-type: text/css'); Quote Link to comment Share on other sites More sharing options...
jarv Posted May 20, 2013 Author Share Posted May 20, 2013 ok, changed that thanks! still not working?! All my styles are broken Quote Link to comment Share on other sites More sharing options...
Q695 Posted May 21, 2013 Share Posted May 21, 2013 Have the CSSes with identical names, and with a specific setting it will pull A, B, C to be output in the correct spot in the head of the page. Quote Link to comment Share on other sites More sharing options...
Eiseth Posted May 21, 2013 Share Posted May 21, 2013 What do you achieve with this anyway? Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 21, 2013 Share Posted May 21, 2013 (edited) Use Less. It supports variables and you can just compile it on your machine using one of several free less compilers (SimpLess, WinLess, etc.) What do you achieve with this anyway? You can use variables. Its great. Edited May 21, 2013 by DaveyK Quote Link to comment Share on other sites More sharing options...
jarv Posted May 21, 2013 Author Share Posted May 21, 2013 (edited) please help, it's not working?! Edited May 21, 2013 by jarv Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 21, 2013 Share Posted May 21, 2013 (edited) Use Less, it was DESIGNED with this in mind. http://lesscss.org/ it works like this: @white: #fff; .div{ background-color: @white; } What else do you want?! Edited May 21, 2013 by DaveyK Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 21, 2013 Share Posted May 21, 2013 just telling us that something you are doing is not working, doesn't help us to help you. you haven't even posted your code that is linking/including the .css file, so we have no idea what any of your code is doing. when you browse directly to the .css file, is the output in the browser what you expect? Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 21, 2013 Share Posted May 21, 2013 just telling us that something you are doing is not working, doesn't help us to help you. you haven't even posted your code that is linking/including the .css file, so we have no idea what any of your code is doing. when you browse directly to the .css file, is the output in the browser what you expect? I think what he is trying to do is output a .css file from a .php file, which is redundant when you use Less. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 21, 2013 Share Posted May 21, 2013 not if the values are dynamic, such as custom styling stored in a database and are being retrieved using php code. Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 21, 2013 Share Posted May 21, 2013 (edited) Why would you store variables in a database. less can use different files, with a single file to import all of them to a single .css file. For one, I have this styles.less // this is the file that has the styles .h2{ color: @red; &.big{ width: @full_width; } } variables.less // this holds the variables @dark_red : #a30f0f; @red: #ff0000; @full_width: 980px; bootstrap.less // this combines both using @import "variables.less" and @import "styles.less" // Core variables and mixins @import "variables.less"; @import "styles.less"; With simpless or winless, if you compile that bootstrap.less file you will get a bootstrap.css file looking like this: bootstrap.css h2{ color: #ff0000; } h2.big{ width: 980px; } also, if one fetches styles from the database on load I would love to see the loading times. Less can be compiled on either the server (using JS) or on your machine, in which case you just upload the CSS. The time difference is little to none, tho for peace of mind I always use the latter. Edited May 21, 2013 by DaveyK Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 21, 2013 Share Posted May 21, 2013 Why would you store variables in a database. one example would be so that each user could have his own settings. Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 21, 2013 Share Posted May 21, 2013 (edited) one example would be so that each user could have his own settings. Lol that was rather badly written by me. What else to store in a database than data. Regardless, I am assuming this is not the case and even if it is, less probably has a much cleaner solution. Edited May 21, 2013 by DaveyK Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted May 21, 2013 Share Posted May 21, 2013 (edited) ok, changed that thanks! still not working?! All my styles are broken i was reading your thread on one of the other programming help forums where you started out the thread by stating that the .htaccess file breaks all your styles. that tutorial contains a comment that EVERY .css file in the folder where the .htaccess file is at must have the header() statement in it. only put your dynamically produced .css files in the folder with the .htaccess file. put regular .css files somewhere else. Edited May 21, 2013 by mac_gyver Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.