Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Getting Content From A Different File

Recommended Posts

Hey,
I think this would be simple to html programmers.. but not to me.
I got a website template to make it easy, and there are boxes at the side that i can just put text in. But what I put in these boxes I want to appear on every page of the site. So by doing that i put a piece of code in telling it to get the text content from an external file. How would I do this? Here is the string at the moment.

Code:

<TD COLSPAN=3 background="images/image_45.jpg"><div align="center"><font color="#FF8000" size="2" face="Verdana, Arial, Helvetica, sans-serif">insert here</font> </div></TD>

Share this post


Link to post
Share on other sites

This can be done very simply in many different programming languages, except for HTML. For some reason there is nothing in HTML that seems to work correctly.

 

However, in PHP, you can simply use the include() function.

 

Where you have 'insert here' replace it with:

<?php include('filename.htm'); ?>

Then, make sure that you save the file with the extension of .php rather than .html

 

If you have any more problems feel free to email or PM me.

Share this post


Link to post
Share on other sites

First of all, what sort of info will be in the file and ultimately in the box? How large is the Table cell?
If the 'box' is large enough, it might be a place to use an iframe to insert information, but there may be scrolbar and or viewport size issues that won't be nice.
Sample here.
Other than that, I don't think Html by itself will handle dynamic info.
Use php 'includes' to fill the box with text is an option, too. Simply 'include' a file by name. The server needs to be php enabled for php scripts to run, though.

<?php include 'filename.txt' ?>
I have a script which requires php enabled to run it and it looks up stuff from flat files.
This Sidebar Generator script looks for files within a specific folder and displays the file names as links.
This Other One reads a list of folder names from a flat file and creates a list of links using the same techniques as above for several folders.
In either case, the list of links is based on the folder contents at the time the script is run. If you want to change a link list, upload/ddelete a file to the various folders.

So it kinda depends on the nature of the content you want to include inside the box, and how 'dynamic' it is.

Share this post


Link to post
Share on other sites

I?d do what rvalkass and jlhaslip suggest. I don?t know any way to make it only with html.But only in case you aren?t familiar with php, notice that you won?t get the result of the includes simply by viewing your website from your HD. You need to have it hosted in a server that understands and execute php scripts, like this (Xisto). :rolleyes:

Share this post


Link to post
Share on other sites

The requirement to have files renamed can be avoided by altering your .htaccess file to include a line as per http://forums.xisto.com/topic/32661-heres-a-nice-and-interesting-way-to-make-comments-in-your-php-files/

Edited by jlhaslip (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.