• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dreamweaver 19.2 color code HTML files as PHP

New Here ,
Sep 28, 2019 Sep 28, 2019

Copy link to clipboard

Copied

Is there a way to color code PHP code inside of HTML files?  I've found solutions for older versions of Dreamweaver but it seems they no longer work.  Seems like this would be a normal, supported feature.

 

Thanks!

Views

254

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2019 Sep 28, 2019

Copy link to clipboard

Copied

You can create your own theme by duplicating one of the existing ones and then you need to add some custom rules to target PHP code:

 

 The basic rule for colouring all PHP code

 

 

.cm-m-clike {
color: #FFC926;
}

 

 

 

add these in addition and play about with the colours to get more specific colouring to your liking:

 

 

.cm-m-clike.cm-comment {
color: #CCC;
}
.cm-m-clike.cm-def {
color: #FFC926;
}
.cm-m-clike.cm-variable {
color: #FFC926;
}
.cm-m-clike.cm-variable-2 {
color: #FFC926;
}
.cm-m-clike.cm-variable-3 {
color: #FFC926;
}

 

 

 

You might also want to add a custom color with this tag which colours the actual PHP opening and closing tags (note it will also color the doctype but its the only solutions to my knowledge to date)

 

.cm-meta {
	color: #FFC926; 
}

 

The code editor is an embedded version of Brackets which uses Codemirror at its heart - unfortunately the documentation for Codemirror code colouring is virtually non-existent. You could also look for Bracket code themes which should work in Dreamweaver.

Paul-M - Community Expert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 28, 2019 Sep 28, 2019

Copy link to clipboard

Copied

LATEST

Okay, did some googling and found out how to edit the main.less file.  I was 'throwing darts' by editing it but I edited both the HTML section and the PHP section like this:

.HTML {
	.cm-meta {
		color: #C68CFF;
	}
	.cm-keyword, .cm-builtin {
		color: #66D9EF;
	}
	.cm-variable-2 {
		color: #A6E22E;
	}	
	.cm-m-clike {
		color: #FFC926;
	}	
	.cm-m-clike.cm-comment {
		color: #CCC;
	}
	.cm-m-clike.cm-def {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable-2 {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable-3 {
		color: #FFC926;
	}	
}
/* PHP Specific Code Colouring */
.PHP {
	.cm-meta {
		color: #C68CFF;
	}
	.cm-keyword, .cm-builtin {
		color: #66D9EF;
	}
	.cm-variable-2 {
		color: #A6E22E;
	}
	.cm-m-clike {
		color: #FFC926;
	}	
	.cm-m-clike.cm-comment {
		color: #CCC;
	}
	.cm-m-clike.cm-def {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable-2 {
		color: #FFC926;
	}
	.cm-m-clike.cm-variable-3 {
		color: #FFC926;
	}	
}

This succeeded in turning all the PHP including the tags to purple.  (The tags are still shown as an error...red circle with an X.)  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2019 Sep 28, 2019

Copy link to clipboard

Copied

Have a read here too

Paul-M - Community Expert

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 28, 2019 Sep 28, 2019

Copy link to clipboard

Copied

DW uses a Brackets code engine now.  And Brackets code themes are on Gitnub.

https://brackets-themes.github.io/

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Alt-Web Design & Publishing ~ Web : Print : Graphics : Media

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines