Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » PHP Development Tools (PDT) » Chaning file type
Chaning file type [message #26379] Thu, 07 June 2007 20:23 Go to next message
Eclipse UserFriend
Originally posted by: omry.yadan.net

I have a file.js.php, which is actually a javascript file with some
minor php preprocessing. is it possible to tell PDT that its a
javascript file for purposes of code completion?
Re: Chaning file type [message #26660 is a reply to message #26379] Fri, 08 June 2007 08:29 Go to previous messageGo to next message
drm / Gerard is currently offline drm / GerardFriend
Messages: 26
Registered: July 2009
Junior Member
> I have a file.js.php, which is actually a javascript file with some
> minor php preprocessing. is it possible to tell PDT that its a
> javascript file for purposes of code completion?

I would advise to use a different file extension (like .pjs or
something) and create a new content-type and file association for it.
You can associate both a JS editor and a PHP editor with it, and use the
"Open with" option to choose between them. Eclipse will remember your
choice the next time you open that file.

The problem with the .js.php extension is that eclipse apparently uses
"first best match" method to match file extensions, e.g. if you would
add .js.php to your file associations, the *.php will match first. I
think this could be reported as a bug, btw, since the best match should
be the pattern that is the longest, or even better: the most specific one.

You should of course be aware that if you 'd use another extension like
..pjs, it must be considered a php file by the webserver. You can do this
in Apache simply by adding a .htaccess file next to it, with a single line:

AddType .pjs application/x-httpd-php

HTH
Re: Chaning file type [message #26701 is a reply to message #26660] Fri, 08 June 2007 08:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: omry.yadan.net

As you pointed out, changing the file extension involves configuring the
web server accordingly.
this is not something I am willing to do (my application is intended to
be as simple as possible to install, even if it makes my life a bit
harder).
what about explicitly setting the type of the file (similar to the way
Eclipse lets the user choose encoding on a per-file basis) ?


drm wrote:
>> I have a file.js.php, which is actually a javascript file with some
>> minor php preprocessing. is it possible to tell PDT that its a
>> javascript file for purposes of code completion?
>
> I would advise to use a different file extension (like .pjs or
> something) and create a new content-type and file association for it.
> You can associate both a JS editor and a PHP editor with it, and use the
> "Open with" option to choose between them. Eclipse will remember your
> choice the next time you open that file.
>
> The problem with the .js.php extension is that eclipse apparently uses
> "first best match" method to match file extensions, e.g. if you would
> add .js.php to your file associations, the *.php will match first. I
> think this could be reported as a bug, btw, since the best match should
> be the pattern that is the longest, or even better: the most specific one.
>
> You should of course be aware that if you 'd use another extension like
> .pjs, it must be considered a php file by the webserver. You can do this
> in Apache simply by adding a .htaccess file next to it, with a single line:
>
> AddType .pjs application/x-httpd-php
>
> HTH
>
>
Re: Changing file type [message #26740 is a reply to message #26701] Fri, 08 June 2007 09:19 Go to previous messageGo to next message
drm / Gerard is currently offline drm / GerardFriend
Messages: 26
Registered: July 2009
Junior Member
omry@yadan.net wrote:
> As you pointed out, changing the file extension involves configuring the
> web server accordingly.
> this is not something I am willing to do (my application is intended to
> be as simple as possible to install, even if it makes my life a bit
> harder).

Fair enough

> what about explicitly setting the type of the file (similar to the way
> Eclipse lets the user choose encoding on a per-file basis) ?


I don't think that is possible, but i'm not sure; at least I can't find it.

Another alternative would be to add the Javascript editor to the *.php
file type (Window->preferences->general->editors->file associations) and
just use "open with".
Re: Changing file type [message #26780 is a reply to message #26740] Fri, 08 June 2007 10:28 Go to previous message
Eclipse UserFriend
Originally posted by: omry.yadan.net

> I don't think that is possible, but i'm not sure; at least I can't find it.
>
> Another alternative would be to add the Javascript editor to the *.php
> file type (Window->preferences->general->editors->file associations) and
> just use "open with".
>
That did the trick.
Eclipse remembers the editor associated with that particular file so it
works fine now.

Thanks.
Previous Topic:Indentation after Single Line Comments
Next Topic:XHTML, CSS Validation
Goto Forum:
  


Current Time: Fri Apr 26 14:54:44 GMT 2024

Powered by FUDForum. Page generated in 0.03476 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top