Inserting file contents into web pages using php

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
mr_nabo
Forum Newbie
Posts: 1
Joined: Sun May 07, 2006 7:38 pm

Inserting file contents into web pages using php

Post by mr_nabo »

Hello all,

Hopefully you can help me here considering what I want to do is quite simple. I'm up to date with some basic HTML, CSS, Flash and have created static web pages for a few clients. I'm now embarking on the dynamic page route and have a splash of PHP programming knowledge (or really a dribble, to borrow a horrible adjective). What I'd like to offer my clients is what I suppose is a basic content management system for text and later on for images so I need not update page after page and leave it to the layman.

I understand you can insert the contents of a text document (with or without the html tags for formatting text?) into a table cell using php. My design layout would be a simple two column table with rows for a header image, footer and links. I'd like to be able to say to my clients, edit this Word document with simple formatting then upload it to this directory via ftp and voila, there's your content in the left column. I say Word doc so they need not know anything about HTML, but maybe this isn't possible?

Is there an easy way to do this? This post seemed like a mixture between design and code so sorry if I've placed my questions in the wrong category.

Cheers.

:D
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Is it as simple as an include() or require()?

You could include a simple text document. Or lots of text documents if you want to do an easy way of updating. For instance you had this setup

Code: Select all

<p><?php require 'descriptive_text.txt'; ?></p>
<p><?php require 'contact_information.txt'; ?></p>
I guess that makes for an extremely simple content management system that would be text only. Ideally you should have a form for the client to update this text file (or database).

You should also just use plain .txt, or .html (if you will allow them to insert html) for your includes or requires.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
WDPEjoe
Forum Newbie
Posts: 4
Joined: Sat May 06, 2006 4:14 pm

Post by WDPEjoe »

I don't know if you're still checking this post (most developers I know, including myself, forget their posts two days after writing them) but, here's the answer I think you're looking for:

Generating page content is what PHP is written for. Consequently, it's easy to add text dynamically (via a file, database, etc) to any page.

If you clients edit a document in word, then upload it, their page will not display correctly (.doc files have a lot of information in the file other than the text, which PHP can't read).

So, barring the use of a parser (*shudder*) you're left with basic text documents. The only way your clients could format them would be to use HTML tags.

At that point, use a simple include() or require() where you want the text and that should do it.
Post Reply