View Full Version : I want to make an external text file for my site, please help! I need php help.
AkewataruAurora
02-14-2006, 07:21 PM
I want to make a single file that I can put my own news on, which will be displayed on several pages on my site, and I want to make it so that I can make changes to this single file and it will display on all of the page I have the news on.
I wrote a topic before about this to ask for help with my site, and many people were kind enough to offer to help, but before I could respond, the forums crashed and the topic was lost.
Several people suggested that the best way to achieve the result I wanted would be to make a php file. I would really appreciate it if someone could help me with this, because I don't know how to make one.
The news I want to put in the file is on this website:
http://jmusiceden.com/
It is in the news column on the right side of the page.
I would really appreciate help with this. Thanks!
This tutorial shows how you can use this tag to include the page you want anywhere.
<?php
/* This example assumes that www.example.com is configured to parse .php
* files and not .txt files. Also, 'Works' here means that the variables
* $foo and $bar are available within the included file. */
// Won't work; file.txt wasn't handled by www.example.com as PHP
include 'http://www.example.com/file.txt?foo=1&bar=2';
// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the
// local filesystem.
include 'file.php?foo=1&bar=2';
// Works.
include 'http://www.example.com/file.php?foo=1&bar=2';
$foo = 1;
$bar = 2;
include 'file.txt'; // Works.
include 'file.php'; // Works.
?>
This example comes from http://us2.php.net/include/
You can also use an iframe...
<IFRAME src="SourcePage.htm" width="100%" height="1000"
scrolling="auto" frameborder="0"></IFRAME>
You just adjust the dimensions of the page you want to frame.
Dave
. .
rjewett
02-14-2006, 10:36 PM
Unless you have programming experience with PHP you don't need to go this route if you just want a simple include capability. IFrames do work if you want to use that type of page layout control.
Server Side Includes were developed to handle the situation you mentioned. You want to code pure HTML pages but you want to include the contents of one file into many pages of your site. HTML SSI is a simple syntax you can use to 'include' files into your HTML main file.
<!--#include http://www.mysite.com/file.html -->
There are a number of commands you can put in an SSI statement besides include. Try reading http://http-server.carleton.ca/~dmcfet/html/ssi.html
WebJDC
02-15-2006, 11:21 AM
i agree SSI would be the best bet here.
be sure any pages that you use that include tag, is renamed to .shtml
WayneHammond
02-15-2006, 03:06 PM
Using includes with ph is very simple. You must save your file with a php extension (usually) for the server to recognize that it must parse the file. To set up a whole website using php, save all of the files you want to incluse with an .inc extension (only to easily recognize which files are include files). The file used to "assemble" the page looks like this:
<?php
include './head.inc';
include './menu.inc';
include ;./content.inc';
include './footer.inc';
?>
Save the file as index.php or whatever you want to use in you r menu list and that's it.
To include a file inside another file:
at the location you want to put the file - <?php include '/yourincludefile'; ?>
If your using php, the contents of the included file will be there.
Note that this is very similar to cgi includes and they will also work as another poster has already pointed out.
WebJDC
02-15-2006, 03:29 PM
i know dreamweaver has built in SSI support and i am not sure if it does PHP.... so if you use dreamweaver or another editor like that, that may be a deciding factor for you.
Dustin
02-15-2006, 06:15 PM
A note about SSI, since I've had alot of tickets with these issues, if your files as HTML, be sure to add HTML to your list in the Apache Handles section of cPanel as SSI.
AkewataruAurora
03-11-2006, 06:04 PM
I appreciate all of the replies I have gotten concerning this, but unfortunately they haven't helped me. I have read the tutorial but they were just too complicated and I couldn't understand them, and I have tried the things people have suggested but evidently I am doing something wrong because it isn't working. The files I create don't show up on the page. If anyone could make the proper file for me and tell me step by step in simple terms how to incorporate it into my pages, I would REALLY appreciate it!
Thanks!
WebJDC
03-12-2006, 02:09 PM
when you upload the ssi pages to your webspace they will work, but not on your local computer, i think the same goes for php
AkewataruAurora
03-12-2006, 04:54 PM
when you upload the ssi pages to your webspace they will work, but not on your local computer, i think the same goes for php
I tried uploading them and then going to my webpage to see if it was working properly, but it didn't show on my page.
WebJDC
03-13-2006, 07:13 PM
can you send a link to this?
maybe i can look...then go through your code and see if you did it wrong or something.
Also...i dont know how computer aware you are..but you are uploading every file right?
AkewataruAurora
04-06-2006, 11:24 AM
I don't know how to make a php file or an SSI file. I tried to create a php file, but it didn't work so I deleted it. I want to make a file for my menu that I can insert on all of my pages, so that I can change my menu on all of the pages by changing one file.
Here is a link to my site that I want to put the file on:
http://jmusiceden.com/
Can someone please help me?
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.