Welcome Guest, Not a member yet? Register   Sign In
View file extension php; can it be html?

Is there a way that I can use html for the file extension to view files?
I ask because it would be nice to be able to use my normal html editors (dreamweaver, expressions, html-kit etc) to develop the view files. As you may know many php ide's such as NuSphere's PhpED IDE can display & develop php & html code within the same editor, dreamweaver can be set up to recognise most coding syntax's within it's ide.

Some purists may just say use a text editor, but it would be nice to develop view files along side css etc within html/php ide's

Any suggestions / help appreciated.

I should declare that I'm new to CodeIgnighter so my apologies if my query is a little basic.


Jonathan Parker

[eluser]Colin Williams[/eluser]
You can:

$this->load->view('file.html', $data);

But there's no guarantee the PHP in file.html will be parsed as PHP without changes to your server configuration.

Sounds like a bad idea to gear your app to your IDE. There are myriad capable IDEs

Hi Colin, I may be new to CodeIgnighter, but I've been developing php apps for over ten years now and I've never heard anybody raise the concern that you do. The 'standard' 'out of the box' Apche + php set-up does guarantee to parse php content within html files.
The reason for my question was that at present I develop within the SilverStripe framework and it was a pain to set-up dreamweaver & expressions to recognize template code within template files (very similar to view file in CodeIgniter). It would have been nice to be able to develop view files in HTML/php format for this reason. Especially when modern IDE's have code recognition intelligence for both within the same editor page, although the CSS functionality within these same IDE's still only applies itself to files with html file extensions.

Thanks for the example though, it gives CodeIgniter yet another tick in the box for me.



[eluser]Colin Williams[/eluser]
EDIT: I was wrong. The file extension does not matter because the PHP parser is already running for the given request. It could be filename.monkeyface if you wanted, but the loader class will look for .php if no extension is provided. Glaringly obvious but I had a slight lapse in memory there.

Quote:to recognize template code within template files (very similar to view file in CodeIgniter)

View files are just PHP files.

Quote:The ‘standard’ ‘out of the box’ Apche + php set-up does guarantee to parse php content within html files.

Really? Because I think I have an 'out of the box' apache 2 install, and it has DefaultType set to text/plain, and I don't see "AddType application/x-httpd-php .html" anywhere in it.

[eluser]Colin Williams[/eluser]
You might want to define your own constant if you intend to use .html view files a lot, or exclusively. I would define it in config/constants.php

define(VIEW_EXT, '.html');

And then:

$this->load->view('view'. VIEW_EXT, $data);

Thanks Collin; your comments have been a great help & are appreciated.
Good thinking about the constant! I'll do that.
I also apologize; having read my post I should have said WAMP/Apache-php type installs as standard !!



Theme © iAndrew 2016 - Forum software by © MyBB