Question

So for my site I needed a way to highlight a php file as css and also enable code hinting as css inside a php file. I am including the php file as a css file using <link href="css.php" rel="stylesheet" type="text/css" /> which works and displays the php file as css. However, the problem is that in Adobe Dreamweaver when I am editing the code for style.php it all shows as black font and code-hinting for css does not work.

This file includes many php variables for displaying the content differently based on user settings and other php variables made by the parent page.

condensed style.php

/*
Style Sheets
....
Copyright © 2012 All Rights Reserved
*/
@charset "utf-8";

#myID {
    background:<?php echo $colorVar; ?>;
}

How can I get dreamweaver to recognize this php file as a css file?

Was it helpful?

Solution 2

After researching and finding tutorials on how to edit Dreamweaver configuration files and none working exactly I finally thought of a solution.

In the comments in the beginning of the php file that I want to be rendered as css put an html style tag like this:

/*
<style>
Style Sheets
....
Copyright © 2012 All Rights Reserved
*/
@charset "utf-8";

#myID {
    background:<?php echo $colorVar; ?>;
}

This works perfectly. It enables syntax highlighting and code hinting as if the rest of the file were css and still has correct php syntax highlighting for <?php ?> tags.

Hope this helps someone else along the way.

OTHER TIPS

The previous answer did not work for me. Whether that was due to a new version of Dreamweaver or because the browsers have changed either way, when putting to the server it did not appear correctly.

What I did to resolve this:

<?php 
if (true == false)
{
    ?><style><?
}
?>

The true == false will never ever happen so anything put in here can be used for comments or IDE cosmetics hence no need to end the <style> tag. This then also puts style colouring throughout the document

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top