RootsChat.Com
General => Technical Help => Topic started by: Malcolm Bull on Wednesday 19 April 06 09:33 BST (UK)
-
I'm quite happy creating HTML pages, but I have a need to be able to incorporate smaller documents into several larger documents. Much like the <IMG> tag brings in images, is there an HTML tag which will bring a small piece of text into a bigger page? This would avoid my having to hold (and update) several copies of pieces of text which I use more than once on my websites.
Does that make sense?
I want to avoid using PHP / Javascript and similar tools if I possibly can.
Malcolm Bull
-
I shall ask my husband for you when he finishes work as he makes web sites for himself and for the RAF so when it comes to all things like that he knows what he is on about. I know he encountered a similar problem but found a way round it. What program are you using to make the pages?
;)
-
Apparently, from what you have said, he says you are using a different program to what he uses and the process is extremely complicated to explain without actually showing you. He did say however that you may find references to what you need on the web and there may be another program you could use rather then java script. Sorry could not be of any help this time.
;)
-
Hi Badgirl,
Very intriguing !!
When I saw your first reply, I was hoping to see a simple answer here, because as far as I know, there is no way in a purely HTML environment to include other files.
PHP, yes, it's just one line <? include("./file.php") ?>
Javasoft I don't know, so I can't comment.
RootsChat webspace can 'do' PHP so that would be no problem, but I don't want to use it, as I regularly burn my website onto CD, along with details of living family members, for distribution just within the family. A PHP solution wouldn't be feasible here.
Can't you persuade your husband to give us a few more details, .... please ?
Bob
-
Ok, i am relaying all info over the phone as he is currently on detachment but he says he need more details of what it is you actually want to do. He is confused by the "purely HTML envronment" remark as the program he uses converts his work into HTML automatically once he has finished. He says what exactly do you want to do as from what you say it sounds like hyperlinking to another page? Then he says you cant possibly mean that as thats far too simple. He also says its always a good idea to put it onto disc, providing its under 700mb and will fit, as a back up.
???
He asks, when you make your own pages for the family do you use microsoft frontpage?
-
Hi Badgirl,
what I need, and what I understand Malcolm would like, is a facility, to include another HTML block within an HTML page, without having to copy it into the page.
For instance, my navigation links bar is the same on every page on my site, so it would be nice to be able to write this block of HTML code once, and store it in a file, and then include it in each page, by referring somehow to this file.
At the moment, I have to copy this block of code onto each and every page, so if I change a link, I have to change every page.
I use a normal text editor to create my pages.
For "purely HTML environment" read plain HTML i.e. no PHP, PERL or JavaScript.
Bob
ps please thank your husband for me.
-
Ok he says you are going hard way round it. He says what you need is microsoft front page as this has a built in HTML text editor. He says that using HTML always sounds impressive but what you need is the web site build option too. *this is where i get lost*, Microsoft front page has an easier web building option which automatically writes the HTML code for you. You can build the site on your computer and use the launch option to upload onto the site of choice.This will copy onto whichever server you choose. You need to use the build option and create a links menu and ALL pages contained within the links menu can be redirected back to whenever requested, therefore having to only build each page once.Microsoft front page gives you more flexibility and therefore cuts out the need to use complicated programs which are not the easiest to use for this type of thing and depending on the need, can be VERY expensive!
Does this help at all?
;)
P.S you can also then turn this into a data disc which will open using IE.
-
Hi Badgirl,
thank him for me, but it's not a route I want to go.
I deliberately stopped using Frontpage because of the bloated HTML and the changes it kept making (it has it's own ideas of what you want to do).
I have tried various other programs and editors, and on the whole, I am happiest with a programmer's text editor.
Thanks again,
Bob
-
Well when i speak to him next i shall tell him to get his thinking cap on. He did say that it was one of the probs with HTML writing that you sometimes have to keep writing codes which is time consuming. He said if you look round on the internet you will find something to graphically display a solution for HTML but it usually involves using things like you have already mentioned.
Sorry could not be of more help but Malcolm joined a GEEK FORUM to see if anyone knew anything on those as they use HTML more frequently.
Karren
;)
-
Hi Karren,
wasn't really expecting a solution, but ever hopeful !!
Once again, many thanks to you and your husband,
Bob
-
From another source, I've found that you can almost do what I want with the
<IFRAME .....>
tag. But I'll have to play around with it a bit as it seems to ignore any tags in the brought-in file, but that may just be my not being familiar with the tag.
Watch this space.
Malcolm Bull
-
Some samples of using iframes to do what has been suggested here can be found at
http://www.htmlcodetutorial.com/frames/_IFRAME.html
One of the problem with iframes is that some older browsers don't support them ... although IE6 & 7 and Firefox v1 & above do.
Another problem is that some adblockers will block iframes
-
I dont know if this is any use to anyone as i have not asked my husband to explain the jargon to me but i came accross it as a link on one of the sites i use and thought of you guys. Its probably useless but try it to see
http://code.google.com/webstats/index.html
;)
-
I posted the same question on an HTML website and there were one or 2 useful suggestions.
Hopefully, you can see the thread at
http://www.webmasterforums.com/html-css/3368-there-tag-like-img-text.html#post11208
Regards
Malcolm Bull
-
Hi Malcolm,
thanks for the link.
iframe might do the trick, I'll have to try it out.
Although I seem to recall seeing something about it being "deprecated" i.e. allowed but not recommended, as it will disappear in a later version.
Not sure about that though, so don't take it as gospel
The second guy is, in effect, saying "use PHP" which is OK on the website, but not for a CD version.
His example seems very convoluted though. If you decide to "go PHP", let me know, there are easier ways :)
for instance (Skeleton programme):
<? include header.htm ?>
your htm code
<? include boilerplate1.htm ?>
more htm code
<? include boilerplate2.htm ?>
more htm code
etc.
<? include footer.htm ?>
I may have to re-think my whole philosophy here, concerning compatible code for website and CD.
Bob
-
Your solution seems to promise what I'm looking for. If it really is as simple as
<? include ...
then please tell me more.
I'm quite happy to consider PHP it's just that I haven't read much about it, and when I start to read about CSS my eyes glaze over and I start to lose the will to live.
Regards
Malcolm Bull
-
and when I start to read about CSS my eyes glaze over and I start to lose the will to live.
looks like a typo to me, shouldn't that read
and when I start to read about CSS my eyes glaze over and I decide: I'm quite happy with what I've got, thank you !!
Seriously though:
In one sense it is as easy as I've explained it above.
The only catch is that the file that uses the includes needs to have the extension php rather than htm or html. The daft thing is, that the files are then read as HTML, which is why we have to keep embedding the php bits in <? .... ?> just so the program knows which bits realy are php !
Try it out on one of the pages you are linking to: (example: freds-biography)
- change the name of the file from freds-biography.htm to freds-biography.php
- change the link on your calling page to freds-biography.php
- create a simple HTML file with a few lines of text: textblock1.htm
- add some <? include textblock1.htm ?> at different places in freds-biograpy.php
- upload to your site (fred's biography, and the page with the calling link) and see if it works
(just tried it on mine and it did !)
Even simpler, don't change the page with the calling link, but just call http://yourwebsitename/freds-biography.php
Then you only have one file to change.
Bob
-
Bob:
I tried to follow your hints. Here's my main PHP file called test.php
<html>
<body>
the cat sat on the mat aa a a a a a a a a a a a a a a
before
===============================
<?include xxx.html ?>
===============================
after
the cat sat on the mat zz zz z z z z z z z zz z z z z z
</body>
</html>
and here's the included section xxx.html
<html>
now is the time for all good men to come to the aid of the party a a a a a a
<b> this is the inserted document </b>
now is the time for all good men to come to the aid of the party z z z z z z z
</html>
and here's the resultant output
the cat sat on the mat aa a a a a a a a a a a a a a a before ===============================
=============================== after the cat sat on the mat zz zz z z z z z z z zz z z z z z
with the included section missing.
Do I have the correct syntax for the <? include tag and do I have the correct tags, especially in the xxx.html text?
Any help would be appreciated.
Malcolm Bull
-
To be hones I am thankful I am using Frontapge, I will look at html very opccasionally but I don't want to
Am i just perverse?
-
Why do you think that you're perverse? It makes sense to use the simplest tools if you're doing regular work and just creating pages of text. However, I'm creating and maintaining over 1100 linked pages from text produced from a non-Windows/non-Miscrosoft database on another computer system, so FrontPage doesn't fit in at all and doesn't offer the flexibility that I need.
Malcolm Bull
-
Hi Malcolm,
I just tried out your example, with one change in the main program::
<html>
<body>
the cat sat on the mat aa a a a a a a a a a a a a a a <br>
before <br>
=============================== <br>
<? include "xxx.html" ?>
=============================== <br>
after <br>
the cat sat on the mat zz zz z z z z z z z zz z z z z z <br>
</body>
</html>
and without the html start and end tags in the xxx.html file
(even if you call the file xxx.php, the contents will always be interpreted as HTML unless you use the <? and ?> PHP tags.)
now is the time for all good men to come to the aid of the party a a a a a a <br>
this is the inserted document <br>
now is the time for all good men to come to the aid of the party z z z z z z z <br>
the br-Tags are just line feeds, to format the text.
You need to load it to your website, as normal home computers don't have PHP, the RootsChat free webspace does :) :)
You can see the results here: http://tutorial.rootschat.net/test.php
Re-reading your reply to Stonechat:
with 1100 linked pages I am wondering whether it might be an idea for you to download a (free) PHP environment like XAMPP, which gives you Apache, MySQL and PHP, so that you can test your pages offline first.
Bob
-
I'm getting to the "it must be me!" stage.
Your example displays fine [I'm using AOL], but when I upload my version to AOL it still misses out the included text. Although AOL displays PHP pages on other websites OK.
I'll try your recommendation abut XAMPP
Thanks again for your help.
Malcolm Bull
-
Just in case anybody else is interested in XAMPP:
http://www.apachefriends.org/en/index.html
-
Hi Malcom,
Did you have any joy getting your code to work?
If not, I do believe I see whathe problem is. Please let me know if you need any further assistance.
Kind regards.
-
Hi Jon75,
Welcome to RootsChat :)
Don't keep us in suspense, why not tell us anyway ?
(even if Malcolm has solved his problem, it might help someone else)
Bob
-
Hi
You can achieve this by using an XML data island.
Lets imagine your main document looks like this example below:
<html>
<body>
This is the main document.<p>
I need to insert the contents of a file here at this place in the document. This is what an xml data island can do:<p>
<xml src="note.xml" id="xmldso" async="false"></xml>
<span datasrc="#xmldso" datafld="sometext"></span>
<p>The main document continues ..........<br>
</body>
</html>
Let's imagine you want to import the contents of a file called note.xml (which is just a plain text file with a .xml filename extension). This is what it looks like:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<note>
<sometext>This is a file that contains
a
a
a
a
a
a
a
a
a
a few lines of text.</sometext>
</note>
So really all you have to do is add a couple of lines of code to your notes.xml file at the top and the bottom and you can effectively import the whole contents of that file into your main document. You store the file contents between the <sometext> tags. It looks like this:
This is the main document.
I need to insert the contents of a file here at this place in the document. This is what an xml data island can do:
This is a file that contains
a
a
a
a
a
a
a
a
a
a few lines of text.
The main document continues ..........
I hope I have understood your problem and provided a solution.
Regards
downside
-
Hi Downside,
I just tried out your example, using the same test file I used for the PHP suggestion:
test2.htm:
<html>
<body>
the cat sat on the mat aa a a a a a a a a a a a a a a <br>
before <br>
=============================== <br>
<xml src="./testinc2.xml" id="xmldso" async="false"></xml>
<span datasrc="#xmldso" datafld="sometext"></span>
=============================== <br>
after <br>
the cat sat on the mat zz zz z z z z z z z zz z z z z z <br>
</body>
</html>
and testinc2.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<testinc2>
<sometext>
now is the time for all good men to come to the aid of the party a a a a a a <br>
this is the inserted document <br>
now is the time for all good men to come to the aid of the party z z z z z z z <br>
</sometext>
</testinc2>
I've uploaded it to http://tutorial.rootschat.net/test2.htm
Unfortunately, there is no sign of the "data island", neither in IE nor Firefox :(
Any ideas why not - it seems simple enough and it would certainly solve some of my problems.
Bob
-
Hi Bob
You have a $ (dollar sign) inserted when it should be a # (hash symbol).
NB you do not include html tags in xml documents, so get rid of the BR tags.
I copied your data into 2 separate files using the hash symbol (although when I copied and pasted your data into Notepad it myteriously changed from a $ into a #)and removed the BR tags and got the following result:-
the cat sat on the mat aa a a a a a a a a a a a a a a
before
===============================
now is the time for all good men to come to the aid of the party a a a a a a
this is the inserted document
now is the time for all good men to come to the aid of the party z z z z z z z
===============================
after
the cat sat on the mat zz zz z z z z z z z zz z z z z z
Regards
downside
-
Hi Downsider,
thanks for that.
It must be something to do with german keyboards and different character sets, because I see a # sign in my code, and in my RootsChat postings.
A question (for anybody reading this):
Do you see 3 hash signs here: # # # ???
I'll look into it tonight, after work
Bob
-
Sorry for getting back, bit I've have some real work to do.
In response to the message from Jon75: no I never did get it to work - I didn't even get XAMPP to download and run. The situation is for my Calderdale Companion website where I have a set of programs which I wrote to collate the entries and prepare the text for uploading, and I just wanted to reduce my dependence on them and let HTML (or whatever) do a bit more of the work, but it's obviously more difficult and more obscure to do this.
Obviously a case of ... if it ain't broke, fix it until it is.
Thanks to all
Malcolm Bull
-
Altering the code above very slightly it works under IE but not under Firefox
html>
<body>
the cat sat on the mat aa a a a a a a a a a a a a a a <br>
before <br>
=============================== <br>
<xml id=text2 src="testinc2.xml" async="false"></xml>
<span datasrc="#text2" datafld="sometext"></span>
=============================== <br>
after <br>
the cat sat on the mat zz zz z z z z z z z zz z z z z z <br>
</body>
</html>
-
After reading some more at the W3 Forums it appears that <xml> is an unofficial tag and while the examples of data islands given at W3 work perfectly well within IE (5 or above) they don't appear to work at all under Firefox.
-
Hi all,
With the first PHP example given I saw that a simple " ; " was missing. To include data in and existing file pulled from another file the following should work fine.
index.php example:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="5" align="center">
<tr>
<td>The data from your normal page in here.</td>
</tr>
<tr>
<td> <?php include ("path/to/yourdata.php"); ?> </td>
</tr>
<tr>
<td>The data from your normal page in here.</td>
</tr>
</table>
</body>
</html>
The yourdata.php will contain the data that you wish to include. This also could be any extension e.g yourdata.html.
The code you tried earlier was:
<? include "xxx.html" ?>
You can see that I have changed this to:
<?php include ("path/to/yourdata.php"); ?>
If yourdata.php is in the same folder as the index.php you can drop the path/to/ part. You can also drop it if you have a base href in you head section.
Hope that is of some help to you.
Kind regards.
-
Further information on enabling xml data islands within Firefox can be found at
http://uk.builder.com/architecture/web/0,39026570,20274592,00.htm
where
at first glance, giving Mozilla XML data island support seems like wizardry, it is accomplished through the use of CSS, JavaScript, and the HTML DOM Level 1.
-
Jon75,
thanks for that. Funny how it works on some set-ups and not on others.
<? include( "filename" ); ?> is definitely the 'correcter' way of doing it.
Falkyrn,
thanks for that information. I also checked the W3 site, and what I wrote seems OK according to them, but I will have another go later.
Anybody,
Still an open question:
Do you see 3 hash signs here: # # # ???
Or 3 Euro signs here: € € € ???
Bob
-
Hi Bob
Yes I can see your hash signs and your Euro signs. If you are using Linux then your keyboard layout might do strange things although usually it means your # signs turn into £ signs rather than $ signs.
About 30 emails ago someone asked if it was possible to import text from an external file without resorting to JavaScript or PhP. I think someone said it was not possible to do this using standard HTML and I offered a way of doing it using XML. My method is a cheats way of doing it as XML has been primarily designed to be used as a database language using unformated data. Typically it is used in this context:-
<individual>
<id>I001</id>
<firstName>John</firstName>
<surname>Smith</surname>
<whenBorn>02 Jan 1901</whenBorn>
<whereBorn>Worthing, Sussex</whereBorn>
<whenDied>02 Feb 1975</whenDied>
<whereDied> Brighton, Sussex</whereDied>
</individual>
So to put a whole paragraph or page of text into one datafield works but it is not its normal use.
As you may be aware there the GEDCOM format designed in 1996 is about to be replaced with XML so it is worth reading up about it and its capabilities as it will be the new standard.
Regards
downside
-
and all of a sudden, it works !!
I took out the BR-tags in testinc2.xml and uploaded, and that was that !!
http://tutorial.rootschat.net/test2.htm
I tried it yesterday withot the BR-tags and it didn't work (IE & Firefox), today it does ???
Don't ask me to explain, the more I work with computers (over 35 years now) the more baffled I get by some of their wierd antics.
Bob
-
Correction:
In IE it works always, in Firefox it works sometimes.
Will check out Falkyrn's Firefox link for XML data islands.
Bob