PHP altenative to frames?

  • Eyesbryte
  • Beginner
  • Beginner
  • User avatar
  • Posts: 46
  • Loc: California

Post 3+ Months Ago

Hello all!

I am designing a site for a client which contains a few pages that need to be updated on a regular basis. They want to do this maintenance themselves but they have no knowledge of HTML. They would like to save their MS Word files as HTML and upload them as such. (I know...sounds crazy!) I would like to create the site so that the header and navigation menus are always available and prefer not to use frames/iframes. I imagine there is a way to do this with PHP but I have not had the opportunity to learn it yet. I am, however, knowledgable in many other programming languages and a fast learner.

If anyone has any ideas on the best way to do this...Please Help!

Thanks!
Eyesbryte
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

I use PHP for reusing headers, menues and footers all the time. If you are the mantainter it's too easy:

Code: [ Select ]
...HTML...
...TABLES...
<? include('menu.html'); ?>
...TABLES for emulating frameset disposition...
<? include('content.php'); ?>
...
  1. ...HTML...
  2. ...TABLES...
  3. <? include('menu.html'); ?>
  4. ...TABLES for emulating frameset disposition...
  5. <? include('content.php'); ?>
  6. ...


I mean, you my add the include() wherever you need to include another PHP or HTML or TXT file.

Of course, if they want to upload it's own generated HTML, well, you will have to browse a directory from PHP (which you can do) or build a control panel DB-based to store information about uploaded documents.

You can do it with PHP, you have to start thinking about "How will the final user upload new HTML files?"
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

I use this kind of includes in my site (http://www.drk.com.ar), actually:

Code: [ Select ]
<body bgcolor="#FFFFFF" text="#0099FF" link="#FF0000" vlink="#FF0000" alink="#FFFF00">
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
  <td width="760" height="80" colspan="5" align="left" valign="top"><? include("header.php"); ?></td>
</tr>
<tr>
  <td width="100" align="left" valign="top" bgcolor="#154255"><? include("menu.php"); ?></td>
  <td width="5"></td>
  <td width="650" align="left" valign="top">
        <br>
        <p align="center">
            <span style="text-decoration: underline; font-weight: bold; font-size: 13px;">
                Welcome to DRK Software site
            </span>
        </p>
...
  1. <body bgcolor="#FFFFFF" text="#0099FF" link="#FF0000" vlink="#FF0000" alink="#FFFF00">
  2. <table width="760" border="0" cellspacing="0" cellpadding="0" align="center">
  3. <tr>
  4.   <td width="760" height="80" colspan="5" align="left" valign="top"><? include("header.php"); ?></td>
  5. </tr>
  6. <tr>
  7.   <td width="100" align="left" valign="top" bgcolor="#154255"><? include("menu.php"); ?></td>
  8.   <td width="5"></td>
  9.   <td width="650" align="left" valign="top">
  10.         <br>
  11.         <p align="center">
  12.             <span style="text-decoration: underline; font-weight: bold; font-size: 13px;">
  13.                 Welcome to DRK Software site
  14.             </span>
  15.         </p>
  16. ...
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Another optioin would be to have the code:
Code: [ Select ]
<?
if(empty($page)) { include_once("main.php");
} else { include_once("$page.php");
]
?>
  1. <?
  2. if(empty($page)) { include_once("main.php");
  3. } else { include_once("$page.php");
  4. ]
  5. ?>

Then for the links for your pages have this:
Code: [ Select ]
<a href="?page=contact">Contact Us</a>

You dont need the .php extension, just make all of your pages .php files or change the else statement to include another extension, and you can have the files in directories but if you want an index file from a directory you have to put something like:
Code: [ Select ]
<a href="?page=files/index">Files - Main</a>

And that should work out just fine for you.
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Posts: 776
  • Loc: Nippon

Post 3+ Months Ago

Switch works extremely well for doing ?page=name type links too. You can create quite the brain for your website without revealing any of your filenames. That's how I usually do things. I think it's a little more classy than having http://www.address.com/filename.php in the address bar, but that's just my tastes.

switch ($page) {
case home:
include ("home.htm");
break;
case news:
include ("news.htm");
break;
default:
include ("index.htm");
}

Simple.
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

Never use a code like this, unless you want your site to be hacked.

Code: [ Select ]
include_once("$page.php");
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Why is that _Leo_?
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

As a general rule, you should never use a variable comming from outside as a path or path component. A malicius user may use it to get access to a particular file of your sistem, and such things.

The way gsv2com has proposed will be fine. The value comming from outside PHP is used in the case, if the value was modified by hand, it won't match and will get you to the index.htm
  • Scorpius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 401
  • Loc: Scorpion Hole

Post 3+ Months Ago

Well, for the way gsv2com said, that would mean you would have to update the index page every time that you wanted to add a new page, but there is a way where you could make a nice little script that would add 2 fields to mysql database and then in the switch, you could just get all the rows out of the database which would solve the whole updating problem.
  • gsv2com
  • Professor
  • Professor
  • User avatar
  • Posts: 776
  • Loc: Nippon

Post 3+ Months Ago

Yeah, you do have tu update the index page every time you add a main section, but most of my websites are database driven and I use the above style for the main pages and let the database do all the work for the sub-sections.

ie ?p=djs&id=1
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

You can update a PHP file, you can use a DB for storing index/page information, you can also parse the incoming variable for strange characters, and then use it for building a path, but you have to be sure your parsing works fine. It is up to you :)
  • Eyesbryte
  • Beginner
  • Beginner
  • User avatar
  • Posts: 46
  • Loc: California

Post 3+ Months Ago

Thanks for all your suggestions! They're very helpful! Now in testing what things would look like, I've save a word file as HTML and included it, I also have a style sheet but it seems that the Word document's style is taking over! http://www.eyesbrytedesigns.com/desertt ... b/test.php

Is there a way to correct this?

Thanks again!
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

mmm.. parsing the file for removing M$Word's style tags.
  • Eyesbryte
  • Beginner
  • Beginner
  • User avatar
  • Posts: 46
  • Loc: California

Post 3+ Months Ago

Ok....I guess I don't know how to do that yet.....time to start learning!

Thanks!
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

Well, check the preg_replace() function, will should work. You will need to learn Perl Regular Expressions.

Post Information

  • Total Posts in this topic: 15 posts
  • Users browsing this forum: Bigwebmaster, Liamw411 and 49 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.