Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Frontpage moves my PHP code?

Posted on 2004-10-23
13
Medium Priority
?
243 Views
Last Modified: 2008-02-01
I use Frontpage 2000 for my simple website. I'm adding a forum to it by using a freeware PHP script. The instructions say to add a 'require' and 'include' statement to the very top of the page... following is what I have in FrontPage when I edit using the html view of the page; notice that the <?php .... block is right at the top; BUT when I actually save the page, Frontpage moves the block to just after <body> tag. Why does it do this and how do I work around it (and does it even matter)?. My page isn't doing what I want ... in my browser, if I do a view/source, you can still actually see the <?php tags in the code. I know that php works ok on my web host, because I've tested a simple stand-alone php file that works ok (a copy of that is also attached). My webpage is at the same level as the "forum" directory, so I think the paths are ok.

<?php
require "forum/orca/of_lang_en.php";
include "forum/orca/of_head.php";
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Forum</title>
<link rel="stylesheet" type="text/css" href="forum/orca/of_style.css" />
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta name="Microsoft Theme" content="zero-blue 011, default">
<meta name="Microsoft Border" content="tl, default">
</head>
<body>
<p>&nbsp;</p>
<h3>Welcome to our forum, a place to collaborate about collaboration.</h3>
<p>First, some requests:</p>
<ul>
  <li>Be courteous and professional</li>
  <li>No spam</li>
</ul>
<p>This forum will be moderated, and inappropriate posts will be deleted.</p>
<p><font size="2">eMail addresses will have extra characters added to prevent
eMail farming by automatic engines. When using an email link, be sure to delete
out this text (it will be obvious in the To: field of your email message).</font></p>
<p>&nbsp;</p>
&nbsp;
<?php include "forum/orca/of_body.php"; ?></body>
</html>

HERE's THE TEST .PHP FILE (FORUM.PHP) THAT WORKS FINE when I visit it directly thru my browser (I just don't have the look and feel of the rest of my website, so was trying to incorporate it into one of my htm pages per the instructions that came with the script):

<?php
require "orca/of_lang_en.php";
include "orca/of_head.php";
?><html>
<head>
  <title><?php echo $fData['pagetitle']; ?></title>
  <link rel="stylesheet" type="text/css" href="orca/of_style.css" />
  <style type="text/css">
body {
  background-color:#ffffff;
  font:normal 100% Arial,sans-serif;
}
  </style>
</head>
<body>
<?php include "orca/of_body.php"; ?>
</body>
</html>

0
Comment
Question by:alicia1234
13 Comments
 
LVL 27

Accepted Solution

by:
Diablo84 earned 600 total points
ID: 12389991
>> Why does it do this

Because to be frank Frontpage is a terrible editor, that being an understatement. It adds unnecessary code, moves code around as you have seen, its just not worth bothering with.

and how do I work around it (and does it even matter)?

Does it matter - depends on the content of those files. If any functions are used which use the http header then yes. I would ensure that its at the top of the page to be on the safe side.

How do you work around it - edit the file in notepad or any other basic text editor. If in doubt, right click the file, select open with and select notepad from the list... or browse for another text editor to open it with if necessary.

The file must have a .php extension and must be accessed via the http protocol (eg locally: http://localhost) otherwise it will not be parsed by the php engine so the php code will not be interpretted and hence will remain in its current form.
0
 

Author Comment

by:alicia1234
ID: 12390005
So ... the "file" that I listed is currently "Forum.htm" in my web ... are you saying that in order for the php to be parsed, the file (page) must have an .php extension (instead of .htm)? (That would certainly explain some of my problem.)
And when you say "edit the file" ... do you mean my forum.htm file? So I would open it in Frontpage, html view, copy everything to notepad, then save as .php file, and then drag that file in to Frontpage?
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12390017
>> are you saying that in order for the php to be parsed, the file (page) must have an .php extensio

yes, you can configure your server to parse .htm extensions but its easier to just rename it to .php

>> do you mean my forum.htm file?

yes but you do not need to open it with Frontpage copy etc etc

The easiest steps to take is this

rename forum.htm to forum.php

right click on the file > open with > select note pad

move the php code to the top of the file where it should be

save the file
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:alicia1234
ID: 12390023
right ... but to do the renaming outside of Frontpage, right?
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12390034
correct

If you think of it like this everything will probably be easier to understand

HTML files, and PHP files (.html,.htm,.php etc) are just text files which contain markup tags and scripting code, that is all.

Frontpage just acts as an easy to use interface to allow you to easily edit the file however it is not needed at all.
0
 

Author Comment

by:alicia1234
ID: 12390078
OK ... I did that ... and I named the file "BESForum.php" and put it in my "forum" folder. Now when I visit the page ... for example, mywebsite.com/forum/BESForum.php, the page content is correct, but it has none of the look and feel of the rest of my website (which uses a theme).
The text in my new .php file is exactly as shown in my first post (except that the paths have "orca" instead of "forum/orca").
I moved the .php file to the root of my website (and changed the paths back to "forum/orca", thinking it might be a path issue for my theme files), but I still get the ugly page.
0
 

Author Comment

by:alicia1234
ID: 12390083
By the way, PHP is new to me, but I have a small amt of experience with ASP ... I should have known that the page had to have a .php extension on it!!!  (Duh!!!)
0
 
LVL 27

Assisted Solution

by:Diablo84
Diablo84 earned 600 total points
ID: 12390097
The forum files may be overriding your stylesheet, difficult to say without knowing what the includes contain.

I would advise looking in this file: forum/orca/of_head.php

and seeing if there is a link to a stylesheet in it, if so replace it with the one you use, you might not need this file depending on what it contains.
0
 
LVL 27

Expert Comment

by:Diablo84
ID: 12390105
Failing that remember the way you have the path at the moment (forum/orca) is relative ie. from the position of the current file so you might want to use an absolute path instead, eg. /path/from/root

The leading / basically means from the root
0
 

Author Comment

by:alicia1234
ID: 12390117
oh boy ... I'm getting in over my head now ;-) .
I don't know much about style sheets ... except that I know what they are. Note that my BESForum.php does itself have a link to the orca stylesheet in it (per instructions from them). I tried taking that out, but that then screws up the look of the forum stuff (buttons in wrong place, etc).
None of the included files have a link to a stylesheet. (I searched them for "link" and also for "css").
I don't really know what my stylesheet is. I'm using a "theme" in FrontPage and there are several .css files in the "_themes/zero-blue" folder in my web: color0.css, color1.css, custom.css, graph0.css, graph1.css, and theme.css. Is there something I should look for to determine which .css file to use?
0
 
LVL 10

Assisted Solution

by:frugle
frugle earned 400 total points
ID: 12390221
if I'm right in thinking a "theme" is a Frontpage Extension and you don't have the same functionality from within php then the two technologies may be incompatible.

I'll reiterate what Diablo has so elequently stated, without the political correctness: Frontpage is Evil.

what you may have to do is redesign your "themes" in CSS to match the forum, or redesign the forum's CSS to match the theme.  IF you plan to change the look and feel of the site in the future, this will involve twice as much work - retheming will not alter the forum CSS and altering the stylesheet will not affect the theme.

Mike
0
 
LVL 18

Expert Comment

by:arantius
ID: 12396323
"Why does it do this?"
To put in my $0.02, because it's a Microsoft product.  All MS produts are built to assume that the program has more knowledge than the user (which is sadly often true) so it automagically does a lot of things for the user.  Not that they're always what the user wants, often because that first assumption is wrong.

"how do I work around it"
Use an editor that doesn't think it's smarter than you.

"(and does it even matter)"
In this case, probably not.
0
 

Author Comment

by:alicia1234
ID: 12413625
I got it to work. The header file contained functions, so it did matter where the include was (had to be in header; couldn't be in body, as FrontPage was forcing it to be.)
Making sure I had a .php extension, and editting the file using Notepad was the trick. To get the same look and feel as my website, I basically cut/pasted all of the "theme" HTML code from the source view of a web page into my .php file. I know this means that if I change themes, I'll have to do this again, but it was quite straightforward to do the copy/paste (once I figured out that was what needed to be done).
Thanks for the help; never would have gotten it done without it.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question