Forum Moderators: phranque
Have read about the how to in your fantastic forums and have tried this myself, but not achieved the desired results
I would like the CSS for a site to be parsed as PHP
the output though seems to result as text or css so I get the contents of the sites code displayed in Firefox or a partial render in IE
you can see it here at <snip>
here is the basic overview of my setup - its hosted on a godaddy shared hosting server - sorry about the long post and thank you for reading this and considering your reply
the top level index.php files has 7 css includes - this should be done from an external top level css file – but as I was experiencing problems I moved everything to the top level php file to see if problem persisted - which it did
I have added <?php Header ("Content-type: text/css");?> to the top of each css file to make sure that its seen as a css file
the CSS style sheets are included like so
<?php
$tempdir = $mainframe->getTemplate();
$template1 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/layout_css.css";
$template2 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/customise_css.css";
$template3 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/rounded_boxes_side.css";
$template4 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/rounded_boxes_top.css";
$template5 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/rounded_boxes_bottom.css";
$template6 = "" . $mosConfig_live_site . "/templates/" . $tempdir . "/css/menus.css";
?>
<style type="text/css" media="screen">
<?php include $template1;?>
<?php include $template2;?>
<?php include $template3;?>
<?php include $template4;?>
<?php include $template5;?>
<?php include $template6;?>
</style>
.htaccess file contents
# Allows css files to be parsed like PHP
AddType application/x-httpd-php .css
Options FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteRule ^(content/¦component/) index.php
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]
RewriteCond %{REQUEST_URI} (/¦\.htm¦\.php¦\.html¦/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule (.*) index.php
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=¦\%3D) [OR]
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
RewriteCond %{QUERY_STRING} (\<¦%3C).*script.*(\>¦%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=¦\[¦\%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=¦\[¦\%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ index.php [F,L]
# Getting Rid of pdf Files
RewriteCond %{QUERY_STRING} ^option=com_content&do_pdf=
RewriteRule ^index2\.php$ - [G]
#
# Getting Rid of print preview Files
RewriteCond %{QUERY_STRING} ^option=content&task=view&id=
RewriteRule ^index2\.php$ - [G]
#
# Stop SE Indexed obsolete pages
redirect /index2.php?option=com_content&do_pdf=1&id=6/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=1/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=16/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=2/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=3/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=9/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=7/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=1/ http://www.example.com/404.php/
redirect /index2.php?option=com_content&do_pdf=1&id=10/ http://www.example.com/404.php/
[edited by: encyclo at 5:46 pm (utc) on Nov. 22, 2006]
[edit reason] url removed and examplified, see forum charter [/edit]
see
[php.net...]
[php.net...]
for further information.
You do have set things correctly up to get css files you include in your html code with <link rel="stylesheet" type="text/css" href="test.css"> treated with the php parser. And if you do include them with <link>, you'll have to have the header command as the very!very! first line in those files - otherwise they'll get an incorrect content-type.
I'll recommend an extension to Mozilla/Seamonkey/Firefox : Live HTTP Headers.
This extension allows you to see the communication between the browser and the server - including the content-type. Firefox strictly follows the content-type as issued by the server, while at least previous versions of IE had a tendency to ignore these and follow the file extension instead.