css editing and auto completion

So due to the fact that all of the CSS is in ELGG is in .php files, my editor (and several others I have tried) does not recognize the CSS and therefore does not colorize nor auto-complete the CSS.

I am currently getting around this my creating two CSS files, the .php version for elgg and then a second file with the .css extension.  I simply place an include in the .php file and place all of my css in the other file.  

Sure, now I have the opposite problem of my PHP inside the CSS file does not get autocompleted or colored.  But I have a lot more CSS than PHP in those files.

Am I the only one who cares about this and if not, what solutions have you all come up with the make your coding a little less painful?

  • Daniel,

    I use Dreamweaver in CS4. The prog does not color code the CSS inside php, but it does color code the php inside css.

    Perhaps you need to search for a more user-friendly prog to use?

    Another suggestion to try is to wrap your css code with <style type="text/css"> and </style>. This will often trigger the color code and auto complete. (I know you will ask if this will affect your php file, I don't think it should because css will always dump excess or faulty code and revert to defaults.. so, I think your file will in any case dump the wrap anyway).

    Hope this helps.


  • Yes, I found the same problem and I am using the same include trick. About the php code inside css, it hasn't be relevant for me either.

  • What editor are you using?  Most editors can switch between highlight modes quite easily but you may have to do it manually.  I use Eclipse occasionally and it even supports multiple highlighting modes depending upon if the PHP interpreter is on or off.

  • @danielwells - very bad methodology - try Komodo Edit or Komodo IDE. It's the hackers' best friend.

  • @Brett, I'm using DW. Maybe I should change to Eclipse but it will require a time that I don't have :)

    @Yakiv, I don't get why it could be a very bad methodology.

  • It is very unclean and uncommon coding (the include is meant for other php files, not for CSS). You're making a mess of the code (complicating the file structure).  ...Just use a better editor.

    Also, if you are experienced in coding, you will not rely so much on auto-completion. This more for novices.

  • @brett I am using netbeans.  As of yet I have been unable to find a way to do this in netbeans.  I was under the impression that Eclipse had the same issues.  

    @Yakiv When I am ready to shell out some money for an IDE I might look at Komodo IDE.  How does the free version compare (Komodo Edit)?  So you are saying it handles this css.php files just fine then?  Also this novice really likes the code completion as it saves me time (the same reason I like auto-complete in my linux shell). 

    This really wouldn't be an issue if the CSS extend method in ELGG didn't assume the php extension.  Then I could use any file I wanted to extend the CSS.  I don't agree with Yakiv that the php include was only meant for other php files, it is meant to include text from other files.  Sure you could make arguments about 'best practices" but the php include just grabs text from other files.  It doesn't care what extension those other files happen to have.

    @carlos although adding the <style type="text/css"> and </style> tags would probably give netbeans th context it needs to recognize the css I don't think it would be a good idea since my css.php file extends the elgg css.php file.

  • @Yakiv, I think having only css in a .php file is more unclean and uncommon. My solution es clear both for experienced and newbies.

    And saying that autocompletion is only for novices sounds a bit arrogant, no offense ;)

  • Whoa guys...Let's take a step back!  I'd never recommend Eclipse...it just happens to be the one IDE I find that does most of what I want with relative ease...a "best of the worst" sort of deal.  A good chunk of my development time is actually spent in vim, and I never use any sort of autocomplete functionality in editors...

    @danielwells -- You're correct in that Eclipse doesn't highlight CSS withing a PHP file...Not sure where I saw that, but it wasn't in the version of Eclipse that I have right now.

    The reason css is contained within PHP files is to allow themes to specify image paths with a variable URL and installation directory.

    I agree with Yakiv that using an include like that is hacky in both PHP and Elgg's framework.  Using include in this way introduces another point of failure and only serves to provide syntax highlighting in an editor.  Definitely not a recommended practice.

  • @morgar - The point of the comment about auto-completion is that if you know what you are doing, you don't need it. Quite honestly, it often gets in my way and I turn it off, especially with linux shell. ;-)

    It is correct that the include can grab text; it is not the point. The point is that it is not the intended use.

    @danielwells - There is a free 21 day trial, for Komodo IDE and here is a feature comparison on their site, between the Edit and the IDE:


    If you go into the Preferences, File Associations, and tell it to associate css.php with CSS, then all of the CSS code gets treated as CSS by the editor and the color coding and autocomplete are on.

    As far as the price, you're not claiming to be a Ukrainian too, are you?  :-)  ;-)  Even I have a licensed copy of the IDE software.