开发者

Eclipse (PDT) annoyingly locks .phtml files to PHP Content Type

开发者 https://www.devze.com 2022-12-11 09:57 出处:网络
I am getting frustrated with PDT. I want the .phtml files to be opened as HTML BUT .phtml is \"locked\" to PHP Content Type and there is no way to unlock it!

I am getting frustrated with PDT. I want the .phtml files to be opened as HTML BUT .phtml is "locked" to PHP Content Type and there is no way to unlock it!

Opening the .phtml files in HTML would make more sense (for Zend Framework users) because .phtml contain more HTML and some Javascript than PHP code.

The question is, wtf would the Eclipse developers lock certain file types? Is there any way to "unlock" this?

If I right click on the file and select Open With -> HTML Editor, then I get this error:

Could not open the editor: org.eclipse.wst.sse.ui.internal.StructuredTextViewer cannot be cast to org.eclipse.php.internal.ui.editor.PHPStructuredTextViewe

Help anyone?

Much appr开发者_运维知识库eciated, Wenbert


Ok - I found this many years later, and had a lot of the same frustrations. Instead of going in to the XML, I finally noticed I could change orders. In my case, I had JBoss tools installed in my Eclipse (not sure why I did that). It put itself as the default editor for PHP, and set it up in an HTML editor. I went to:

Window -> Preferences -> General -> Editors -> File Associations

Clicked on *.php on the right (and yes, all my associated editors are locked).

I clicked on 'PHP Editor...' and then clicked the 'Default' button.

In the end, the fix you find always seems obvious. In my case, I smacked my head.

Greg

Eclipse (PDT) annoyingly locks .phtml files to PHP Content Type


This is caused by a bug in the PHP code folding. Turn off PHP code folding as a workaround, under Preferences, PHP -> Editor -> Code Folding.


I could be misjudging your question, but I think what you're actually asking is how to remove the "locked" flag from a content type in Eclipse/PDT instead of getting a code folding error. Those content types are locked to a particular extension if they're defined in the plugin.xml file that defines that content type. Here's a snippet very similar to what you're looking for:

<!-- PHP Content Type declaration -->  
<extension  
    point="org.eclipse.core.contenttype.contentTypes">  
    <content-type  
        base-type="org.eclipse.core.runtime.text"  
        file-extensions="php,php3,php4,php5,phtml,inc,phps"  
        id="phpsource"  
        name="%content-type.name.0"  
        priority="high">  

If you notice the file-extensions line, just delete phtml from that list and restart eclipse (possibly with the -clean flag) and it should no longer be locked. The trick is finding the right XML file, especially if they're often inside .jar archives as well.


That looks like bug 241468, and it has been fixed late 2008 for PDT2.0.0

So what PDT version are you using? The latest one (2.1 with eclipse3.5) should not have this issue anymore.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号