Click to See Complete Forum and Search --> : Loading variables from external text


MastahUK
02-19-2003, 02:28 PM
I have just started creating my website, which I intend to create a lot of pages for. I would like them all to have the same layout and information around the outside of the page and only change one particular table located in the main section of my site for each page.

I was wondering if I could use only one html page, but link external .txt files containing only the script for the main section into the correct place. This text file would have to contain html tags as well if possible.

I really need the script to allow me to load a .txt file as a variable. Is it something like "var test = loadvariables("text.txt")?

If this is possible, or if there is an even better way of doing this, could you please give me the appropriate lines of script so I can adapt them for my own use.

pyro
02-19-2003, 02:34 PM
If your server supports PHP or SSI, here's how to do it.

PHP (.php)
<?PHP
include("yourfile.txt");
?>

SSI (.shtml)
<!--#include file="yourfile.txt"-->

MastahUK
02-19-2003, 02:41 PM
Would this allow me to do something like this:

<body>
<table>
<tr>
<td>blah
<td>blah
</tr>
<tr>

<!--Load external .txt files from here...-->

<table>
<tr>
<td>Stuff in
<td>main content
<td>that changes.
</tr>
</table>

<!--...to here>

</table>
</body>


With the bit in the middle being the contents of the .txt file. Only problem is that I need to be able to change what is loaded in the middle using some sort of code without having to creat multiple html files. Is this possible?

For example, how would I click a link from this page that could change the loaded text from the file 'home.txt' to the text 'maps.txt'.

For an idea of the layout of the page and what needs to be loaded, it is for this site: http://www.mastahuk.com

pyro
02-19-2003, 02:45 PM
Check if this thread helps you... http://forums.webdeveloper.com/showthread.php?s=&postid=21706

MastahUK
02-19-2003, 02:55 PM
That looks like just what I need, thanks alot!

MastahUK
02-19-2003, 03:09 PM
I just tried it and it works great! There is only one problem: it creates a nasty looking white border around the <dev> </dev> section. See what I mean here: http://www.mastahuk.com/index1.php

How can I get rid of this?

pyro
02-19-2003, 03:14 PM
Change <div id="mydiv" style="border:1px solid"> to <div id="mydiv">

MastahUK
02-19-2003, 03:22 PM
Thankyou :)

If you have noticed I am not at all fimiliar with php.