how to get css highlighting and hinting for php files in dreamweaver that are being read as css files?

Issue

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?

Solution

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.

Answered By – amaster

Answer Checked By – Jay B. (AngularFixing Admin)

Leave a Reply

Your email address will not be published.