Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > PHP question

PHP question
Thread Tools
Mac Enthusiast
Join Date: Jan 2001
Location: Alberta, Canada
Status: Offline
Reply With Quote
Aug 21, 2001, 03:16 PM
 
I am working on a new site and I was wondering how exactly I could have one template file and use PHP to place content in it instead of having dozens of large files. I want to be able to edit the template so the change is seen on all pages instead of editing many files.

TIA
     
Professional Poster
Join Date: May 2001
Location: North Dakota, USA
Status: Offline
Reply With Quote
Aug 21, 2001, 05:28 PM
 
You could probably do this a few ways, but here's the method I would use:
1) Create some file (we'll call it viewArticle.php ) that contains your page's main look
2) Inside viewArticle.php , have the php include a text file that you pass as an argument to the url (say, if you want to display a contact page, you could make a link to the page like this:
< a href = "viewArticle.php?article=contact" >
3) Make sure you have a proper text file that can match up with the article argument you pass the php document.
That wasn't explained too good, but maybe you'll get the idea... someone could explain it more elegantly
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: nj / ny
Status: Offline
Reply With Quote
Aug 22, 2001, 12:10 AM
 
hi ,

i would appreciate you trying to explain it more completely too.

i want to do the same thing .

i am using a whole content management system to achieve this right now when all i need is a single template page with updated content in one cell of the table.


the only other thing that i use from the content management system is the "chron" .

i can load up a months worth of articles and instruct each new article to post at 8 am every morning.

if i could do the "chron" to up date the content cell in the template
i would get rid of the whole content management system.


don't get me wrong this system saved my ass when i really needed it and it might be useful to you if your host will play balland you have php 4 and mysql loaded on your host server.. it's powerful and it's free open source. go see it at phpnuke.org the maker of it.

i would still love to hear a more complete explanation.
     
Grizzled Veteran
Join Date: Jan 2000
Location: California
Status: Offline
Reply With Quote
Aug 22, 2001, 11:51 PM
 
kind of a simple example, but if I have read your post right, this would do it:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
&lt;?

include (<font color = red>"header.inc.php"</font>);

$today = date (<font color = red>"mdY"</font>);
include (<font color = red>"dailys/$today.txt"</font>);

include (<font color = red>"footer.inc.php"</font>);

?&gt;
</font>[/code]

The header and footer would be for your site header and footer, then you would basically place you daily files in the 'dailys' directory and name your files like 08222001.txt. The script will get the date and display the file with that date.

Is this what you needed?
     
Fresh-Faced Recruit
Join Date: Mar 2001
Location: nj / ny
Status: Offline
Reply With Quote
Aug 23, 2001, 02:21 PM
 
yes ,

that is what i'm talking about.

could it possibly be that simple?


the only addition to it now would be adding a time of day (8am) for it to call the new content.

i won't be able to test it until next week but if that works , that would be fantastic.


oh , and ...how about :


include ("body.inc.php");

or some such thing?

the template page that i am trying to call is a .htm consle that is built out of .gif slices.


tia
     
Registered User
Join Date: Apr 2000
Location: Melbourne, Australia
Status: Offline
Reply With Quote
Aug 27, 2001, 04:01 AM
 
Originally posted by t6hawk:
<STRONG>I am working on a new site and I was wondering how exactly I could have one template file and use PHP to place content in it instead of having dozens of large files. I want to be able to edit the template so the change is seen on all pages instead of editing many files.

TIA</STRONG>
FastTemplates library for PHP is designed to to exactly what you want. You can have your designers design HTML and put in {placeholders} where you want the dynamic (PHP) content to be replaced. You have one (or several) HTML templates. Several web pages may use the same HTML template. You can change the template and all pages using the template are updated. Fantastic! I'm learning about it now at uni. FastTemplates is open source (free). You'll find it at
http://www.thewebmasters.net/php/FastTemplate.phtml

There are a few tutorials for using FastTemplates suchs as one at www.phpbuilder.com

Now... if only I could compile and install PHP on my MacOS X. (can't get "pushd" to work in Terminal for the installation).

Sam
samv@netspace.net.au
     
Dedicated MacNNer
Join Date: Oct 2000
Location: Copenhagen, Denmark
Status: Offline
Reply With Quote
Aug 28, 2001, 04:50 AM
 
Originally posted by Sam Venning:
<STRONG>
Now... if only I could compile and install PHP on my MacOS X. (can't get "pushd" to work in Terminal for the installation).
</STRONG>
In case you don't know the sites, you could check if Stepwise, Marc Liyanage or Webmonkey can help you out.

Peter

[ 08-28-2001: Message edited by: peterthorn ]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:39 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2