Solved

Frontpage moves my PHP code?

Posted on 2004-10-23
236 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
Question by:alicia1234
    13 Comments
     
    LVL 27

    Accepted Solution

    by:
    >> 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
    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
    >> 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
     

    Author Comment

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

    Expert Comment

    by:Diablo84
    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
    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
    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
    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
    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
    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
    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
    "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
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    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.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    875 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now