Opening and editing php files

New to web-building ? Simple answers to "How do I . . .?"

Moderators: agsone, Neil Parks, gregtutor, BobCP, Lem3

Opening and editing php files

Postby dbskompozer on Tue Sep 02, 2008 7:16 pm

I have searched the Internet for help on opening and editing php files using Kompozer and have found mixed solutions to the problem. Surely there must be an easy way to handle this file type? I have generated a large site using php includes using FrontPage and would love to transfer the site to Kompozer. The site is http://www.imperiallakes.com.

Thanks in advance for any help.
dbskompozer
 
Posts: 2
Joined: Tue Sep 02, 2008 1:59 pm

Postby BobCP on Tue Sep 02, 2008 7:28 pm

Kompozer will open PHP files natively but won't display the merged content. The page either needs to be published to a server or have a PHP interpreter on your local machine.

Front Page writes quite a bit of non-compliant code and Kompozer won't be happy with it. Don't expect a smooth import of FP pages.
BobCP
Moderator
 
Posts: 1000
Joined: Sat May 26, 2007 10:03 am
Location: Connecticut

Postby wink0r on Tue Sep 02, 2008 8:21 pm

To work with php files in KompoZer you will need to install the handcoder extension available at: http://fabiwan.kenobi.free.fr/HandCoder/

Also put a php comment on the first line of the page before the doc type. I use <?php // Made with KompoZer ?>, but any php comment will work. This will stop KompoZer from doing some nasty things to your code.
wink0r
 
Posts: 1236
Joined: Tue Aug 28, 2007 10:10 pm
Location: East Coast - USA
Country: United States (us)

Kompozer and PHP

Postby dbskompozer on Fri Sep 05, 2008 2:04 pm

Many thanks for your inputs.
dbskompozer
 
Posts: 2
Joined: Tue Sep 02, 2008 1:59 pm

Postby piotrmikula on Fri Sep 05, 2008 9:37 pm

How do i install that in Kompozer? I'm having similir problem, where PHP code breaks in Kompozer
piotrmikula
 
Posts: 3
Joined: Fri Sep 05, 2008 7:13 pm

Postby wink0r on Fri Sep 05, 2008 10:14 pm

wink0r
 
Posts: 1236
Joined: Tue Aug 28, 2007 10:10 pm
Location: East Coast - USA
Country: United States (us)

Postby piotrmikula on Fri Sep 05, 2008 11:09 pm

thanks, I installed Handcoder it but it's not launching my ext app, TextEditor..not ure what I'm doing wrong
piotrmikula
 
Posts: 3
Joined: Fri Sep 05, 2008 7:13 pm

Postby gregtutor on Sat Sep 06, 2008 1:05 pm

Well, it won't open in the Source View.

I just hit F6, but you could always do: TOOLS>HANDCODER>TEXT EDITOR.

You have defined your editor in Handcoder, haven't you? TOOLS>HANDCODER>OPTIONS...
Greg Chapman
http://www.gregtutor.plus.com
Helping new users of KompoZer and The GIMP
gregtutor
Assistant Admin
 
Posts: 2215
Joined: Wed Jun 20, 2007 8:25 am
Location: West Norfolk, UK
Country: England (en)

Postby Neil Parks on Tue Sep 09, 2008 6:17 pm

wink0r wrote:Also put a php comment on the first line of the page before the doc type. I use <?php // Made with KompoZer ?>, but any php comment will work. This will stop KompoZer from doing some nasty things to your code.

This has never worked for me. Could that be because I don't use Hand Coder?
"Program in haste; debug at leisure."
http://www.hjcs.org
Neil Parks
Moderator
 
Posts: 289
Joined: Tue May 29, 2007 5:13 pm
Location: Beachwood, Ohio USA!

Postby gregtutor on Tue Sep 09, 2008 7:33 pm

On the basis of this quote from the Handcoder site:
Better ASP/JSP/PHP support

* WYSIWYG edition of HTML fragments (Nvu won't add headers)
* able to keep a prolog before the DOCTYPE
* open *.php files on Linux, resizable "Insert PHP code" window, and other small corrections ;-)
* (experimental): ASP/JSP tag support (still in progress)

I'd say that the answer is YES!
Greg Chapman
http://www.gregtutor.plus.com
Helping new users of KompoZer and The GIMP
gregtutor
Assistant Admin
 
Posts: 2215
Joined: Wed Jun 20, 2007 8:25 am
Location: West Norfolk, UK
Country: England (en)

Postby gloricon on Tue Feb 03, 2009 4:32 pm

I am setting up a website: gloriousconfusion.com. I am using Komposer. Someone has been helping me and I have created about 40 pages. They are all supposed to have the same navigation bar and links. She told me to create all the pages with a php extension. I have done this and the symbol PHP in a yellow box shows on the column where the navigation bars should be, but when I have transferred the pages onto the Website, using Coffee Cup, the Navigation bars have disappeared completely on virtually all the pages except my home page, and some of the navigation links are incorrect, so there seem to be two different navigation bars on the website and often none at all. When I look at the Source, the correct php code does show on all the pages, but it is typed in pale purple instead of dark type (don't know if that is relevant). Anyway she tells me that I need to install the Handcoder Extension from http://fabiwan.kenobi.free.fr/.

I went on to that site and found HandCoder, and it doesn't show you how to install HandCoder. It talks about HTML Tidy and NVU (nothing about HandCoder)and now I don't know what to do or what they are. I am very new to all this, and have not learnt HTML code. Please could you explain what I need to do. I emailed them to ask how to download the Handcoder but they have not come back to me except the moderator said that I am not a member. Well, I KNOW that, because I don't know how. Is HTML Tidy and NVU part of PHP?
gloricon
 
Posts: 3
Joined: Thu Sep 04, 2008 7:56 pm

Postby agsone on Tue Feb 03, 2009 5:15 pm

To avoid further confusion, glorious or otherwise, let's start with some definitions:

Nvu: the predecessor to KompoZer - don't use it (i.e. stick with KompoZer)

Handcoder: an extension that was originally written for Nvu but works seamlessly with KompoZer. This allows you to combine the WYSIWYG interface of KompoZer with a text editor which allows you play with the code directly - something you should only do if you have a some confidence in what you are doing (and are good at making back-up copies). Also works with ...

HTML Tidy: completely separate program which attempts to take poorly formatted code (line breaks all over the place, extra spaces, minor errors etc.) and convert it to something that is far easier to read and has fewer errors

Text editor: a program that is used primarily to generate the text documents that form the basis of computer code - not to be confused with a word processor which adds all sorts of hidden formats to make the output look nice

PHP: computer programming language - used in this context to allow the web server to combine various files to generate an HTML file (HTML being a different programming language to PHP) which is then sent to the viewer's browser. Not as intimidating as it sounds but not for complete newbies.
agsone
Moderator
 
Posts: 1059
Joined: Mon May 21, 2007 7:33 pm
Location: New York, USA
Country: Scotland (sp)

Postby agsone on Tue Feb 03, 2009 5:25 pm

gloricon wrote:I went on to that site and found HandCoder, and it doesn't show you how to install HandCoder.

What about this part of the Handcoder page? I can't deny that it is a bit terse but I think it is a bit unfair to say there aren't any installation instructions. Regardless, here are some extended instructions I've posted on this forum before:
agsone wrote:Click on the relevant flag in the top left box in this page and download it to the same folder as KompoZer;
Open KompoZer and go to the Extensions option in the tools menu, click the install button and navigate to the handcoder.xpi;
Restart KompoZer and go to the Tools Menu, select Handcoder and then options;
Link it to the text editor of your choice, NotePad will do for now if you are on Windows, search the forum for Windows/Mac alternatives;
Open an html file, (possibly hit Save), then go Tools - Handcoder - Text Editor;
Run round room in triumph, Save often.
agsone
Moderator
 
Posts: 1059
Joined: Mon May 21, 2007 7:33 pm
Location: New York, USA
Country: Scotland (sp)

Postby agsone on Tue Feb 03, 2009 5:58 pm

Now on to your site.
gloricon wrote:Someone has been helping me and I have created about 40 pages.

Ouch - I recommend shelfing at least 37 of those for now, you need to get some basics sorted out first.
gloricon wrote:They are all supposed to have the same navigation bar and links. She told me to create all the pages with a php extension. I have done this and the symbol PHP in a yellow box shows on the column where the navigation bars should be, but when I have transferred the pages onto the Website, using Coffee Cup, the Navigation bars have disappeared completely on virtually all the pages except my home page, and some of the navigation links are incorrect, so there seem to be two different navigation bars on the website and often none at all. When I look at the Source, the correct php code does show on all the pages, but it is typed in pale purple instead of dark type (don't know if that is relevant). Anyway she tells me that I need to install the Handcoder Extension from http://fabiwan.kenobi.free.fr/.

It sounds like your friend is getting you to set up PHP includes. This is very sensible when you have a little bit of comfort handling the code as you can change the menu on every page by editing just the one file (lets say menu.php, I realize that you've got this part). The problem is that there is a fair bit of scope for something going wrong (especially if you haven't got round to using a text editor) and we can't see what you have done as all the php code is removed by the server before we see it. I've got a couple of ideas of what is going on but it might be easier if you were to paste the first ten or so lines (including and after the <body> tag) of a file that works and one that doesn't into this thead - we can look at the patient directly that way.

On a more general issue, and why I am keen that you don't get stuck into too many pages just yet, I see that the style of your website is coded directly into each page. This means that if you decide you want to tweak the look (say changing the colour of your background) you will have to edit every single page. If you were to use a CSS-based format for the site you would be able to make global stylistic changes by editing just the one file (the stylesheet) - CSS is to style what PHP include is to content. This would have the added benefit of getting you away from the table-based format which is a good thing for more reasons than is worthwhile revisiting here (browse around the forum for more on this).

Good luck, looking forward to sorting out your include issue.
agsone
Moderator
 
Posts: 1059
Joined: Mon May 21, 2007 7:33 pm
Location: New York, USA
Country: Scotland (sp)

Postby BobCP on Tue Feb 03, 2009 7:49 pm

I see lots of likely errors in links like this (double /earrings)

http://gloriousconfusion.com/earrings/earrings/earrings_main.php

Because you use sub-directories for many of your files (not a bad thing), I suspect that your includes don't point to the original directory that contains your menu.
BobCP
Moderator
 
Posts: 1000
Joined: Sat May 26, 2007 10:03 am
Location: Connecticut

Next

Return to Beginner Q & A


Who is online

Users browsing this forum: tony and 1 guest