This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Dreamweaver > December 2005 > Highlighting both PHP and CSS syntaxes in one file





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Highlighting both PHP and CSS syntaxes in one file
Fred Perrin

2005-12-14, 10:48 pm

Hello,

I am new to Macromedia Dreamweaver, I've just bought Macromedia Studio 8. In
fact I often use CSS files generated by PHP scripts within the web sites I
create. It's why this kind of files has the .php extension, and Dreamweaver
recognizes them as PHP files used to generate HTML tags instead of CSS
attributes. But it would be great if Dreamweaver could be able to recognize my
files as CSS with nested PHP code... I've looked into the preferences dialog
box, syntax highlighting item, without finding any solution.

Here is a small example of a PHP/CSS file :

<?php

$blue = '#101080';

?>

a:link {
color: <?php echo $blue; ?>;
text-decoration: underline;
font-weight: bold;
}

If someone had a solution, it would be great!
Thanks a lot.
I'm a French student, I know my English should be better...

Randy Edmunds

2005-12-14, 11:06 pm

Hi Fred,

Yes, you can do that, but you'll need to manually edit some .xml files.

First of all, when I say "edit a file", I mean "copy a file from the
Application Configuration folder to the User Configuration folder, and
then edit the file in the User configuration folder". You shouldn't edit
files in the Application Configuration folder. If you're not sure what
this means, then read this TechNote:

http://www.macromedia.com/cfusion/k...cfm?id=tn_16420

First, shutdown DW.

Then, edit each .xml file in the Configuration/CodeColoring folder and
add "PHP_MySQL" (if it's not already there) to all of the doctype
attributes (comma separated list) where "CSS" exists.

Restart DW and you should be good to go.

Hope this helps,
Randy


> I am new to Macromedia Dreamweaver, I've just bought Macromedia Studio 8. In
> fact I often use CSS files generated by PHP scripts within the web sites I
> create. It's why this kind of files has the .php extension, and Dreamweaver
> recognizes them as PHP files used to generate HTML tags instead of CSS
> attributes. But it would be great if Dreamweaver could be able to recognize my
> files as CSS with nested PHP code... I've looked into the preferences dialog
> box, syntax highlighting item, without finding any solution.


Fred Perrin

2005-12-15, 6:16 am

Hi Randy,

Thanks a lot for your quick answer!

But I've tried, that doesn't work... the line I've modified is:

<scheme name="CSS" id="CSS" doctypes="CSS" priority="50">

I've replaced it by:

<scheme name="CSS" id="CSS" doctypes="CSS,PHP_MySQL" priority="50">

In file (I use Mac OS X Tiger):

/Users/fwed/Library/Application Support/Macromedia/Dreamweaver
8/Configuration/CodeColoring/CodeColoring.xml

But when I open a .php file with CSS in it (and with the header <?php
header('Content-type: text/css'); ?> to serve it as CSS on the Apache server),
Dreamweaver still recognizes it as a PHP file in XHTML mode...

Perhaps there is no real solution to this issue!

Thanks again,

Fred

Randy Edmunds

2005-12-15, 6:23 pm

Hey Fred,

Yes, DW only recognizes CSS in these cases:

1. .css file extension
2. contained in <style> tag
3. contained in style="" attribute

I think that what you want to do may be possible by customizing DW
documenttypes and writing a canRecognizeDocument() function for the
PHP_MySQL Server Model, but it's a lot of work and you may lose some
other functionality along the way.

Maybe configuring your server to look for PHP code inside .css files is
easier?

Hope this helps,
Randy


> But I've tried, that doesn't work... the line I've modified is:
>
> <scheme name="CSS" id="CSS" doctypes="CSS" priority="50">
>
> I've replaced it by:
>
> <scheme name="CSS" id="CSS" doctypes="CSS,PHP_MySQL" priority="50">
>
> In file (I use Mac OS X Tiger):
>
> /Users/fwed/Library/Application Support/Macromedia/Dreamweaver
> 8/Configuration/CodeColoring/CodeColoring.xml
>
> But when I open a .php file with CSS in it (and with the header <?php
> header('Content-type: text/css'); ?> to serve it as CSS on the Apache server),
> Dreamweaver still recognizes it as a PHP file in XHTML mode...


Fred Perrin

2005-12-16, 3:16 am

Hi Randy,

You're right, perhaps configuring my Apache server to parse .css files in
order to look for PHP in them could be far much cleaner... before doing this, I
like very much the "Reference" window in Dreamweaver (with O'Reilly articles),
and I use it to write my CSS attributes, even without CSS syntax highlighting,
it helps a lot!
And I would like to thank you for all your answers!
As a student, Dreamweaver is now my favorite web developing application...

Fred

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews