• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
View file extension php; can it be html?

#1
[eluser]JP_Notts[/eluser]
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.

Regards.

Jonathan Parker

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

Code:
$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

#3
[eluser]JP_Notts[/eluser]
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.

Regards.

Jonathan

#4
[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:
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.

#5
[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

Code:
define(VIEW_EXT, '.html');

And then:

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

#6
[eluser]JP_Notts[/eluser]
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 !!

Regards.

Jonathan


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.