SharkBait Posted May 19, 2006 Share Posted May 19, 2006 Hi, I've added .css files to my AddHandler in my Apache config so that it will parse my CSS for php. Though I don't think its working.[code=php:0]/* CSS File */body { background-color: #fff; margin: 0px auto; text-align:center;}.../* Custom Content CSS */<?phpif(isset($CUSTOMSTYLE)) { echo $CUSTOMSTYLE;}?>.../* EOF */[/code]And now the script I am trying to use...[/code]<?php$CUSTOMSTYLE = "div.row { clear:both; padding-top: 10px; } div.row span.label { float: left; width: 100px; text-align: right; } div.row span.formw { float: right; width: 335px; text-align:left; }";require("includes/header.html");// header.html has proper <link href="style.css" blahblah....// Display form?><form><div class="row"> <span class="label">Blah</span><span class="formw"><input type="text" /></span></div></form>[/code]Anyway when I use a plugin with Firefox to show me the css file for the page, it displays nothing under the /* Custom Content CSS */ where I thought it would echo. Am I doing this wrong? Or can this not be done??I don't want gigantic stylesheets and thought this would allow me to make the file itself small and be able to customize the 'content' pages when they are served. Quote Link to comment https://forums.phpfreaks.com/topic/10015-custom-css-with-php/ Share on other sites More sharing options...
kenrbnsn Posted May 19, 2006 Share Posted May 19, 2006 Yes, this can (and has been) done. You need to make sure you use[code]<?php header('Content-type: text/css'); ?>[/code]at the start of your file so the information is served correctly.You may also want to use these headers also:[code]<?phpheader('Expires: Tue, 22 May 1988 03:20:00 GMT');header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');header('Cache-Control: no-store, no-cache, must-revalidate');header('Cache-Control: post-check=0, pre-check=0', false);header('Pragma: no-cache');?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/10015-custom-css-with-php/#findComment-37214 Share on other sites More sharing options...
SharkBait Posted May 19, 2006 Author Share Posted May 19, 2006 [!--quoteo(post=375282:date=May 19 2006, 10:03 AM:name=kenrbnsn)--][div class=\'quotetop\']QUOTE(kenrbnsn @ May 19 2006, 10:03 AM) [snapback]375282[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yes, this can (and has been) done. You need to make sure you use[code]<?php header('Content-type: text/css'); ?>[/code]at the start of your file so the information is served correctly.You may also want to use these headers also:[code]<?phpheader('Expires: Tue, 22 May 1988 03:20:00 GMT');header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');header('Cache-Control: no-store, no-cache, must-revalidate');header('Cache-Control: post-check=0, pre-check=0', false);header('Pragma: no-cache');?>[/code]Ken[/quote]Now do I put that in the script that is wanting to use the custom CSS or does that go alongside the the header.html? Quote Link to comment https://forums.phpfreaks.com/topic/10015-custom-css-with-php/#findComment-37224 Share on other sites More sharing options...
SharkBait Posted May 19, 2006 Author Share Posted May 19, 2006 I have this in survey.php[code]<?php$CUST_STYLE = "div.row { \n clear:both; \n padding-top: 10px; } ";require("includes/header.html");?>HTML stuff here<div class="row"> Blah</div>[/code]Now my stylesheet has the[code]if(isset($CUST_STYLE)) { echo nl2br($CUST_STYLE);} else { echo "NOT FOUND";}[/code]But when I look at the CSS it always echos NOT FOUND. I'm unsure why the $CUST_STYLE isnt being seen even though it declared before the require() Quote Link to comment https://forums.phpfreaks.com/topic/10015-custom-css-with-php/#findComment-37249 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.