×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Inserting same line of text of every web page - "link" insert?

Inserting same line of text of every web page - "link" insert?

Inserting same line of text of every web page - "link" insert?

(OP)
Hello

I've a copyright sentence which goes at the bottom of every web page - unfortunately there are over 5000 of these pages (all transcripts of old documents).

Is there a HTML tag which might "import" this line? They are static HTML pages, but I would like to update one file with the updated year and wording rather than doing it on all the pages manually.

I don't see anything, but I think I might not be searching correctly.

thank you for helping

____________
Pendle

RE: Inserting same line of text of every web page - "link" insert?

Hi

5000 static HTML files is quite bad idea. Even if your web server is serving static files, those should be generated based on some template(s) so you can re-generate them whenever needed.

There would be a couple of ways :
  • JavaScript with or without AJAX : needs a script block or scrip file included in each HTML file, the inserted note will not be part of the page content
  • iframe : needs an iframe tag in each HTML file, the inserted note will not be part of the page content
  • SSI : needs a special tag in each HTML file, needs server configuration, the inserted copyright note will be part of the page content
  • static generator : needs a special tag in each HTML file, the inserted copyright note will be part of the page content
Personally I would prefer to use a static generator. Of course, given the amount of files probably not a readily available one, but a custom made. If the HTML files already contain the copyright note, then would use sed or some other text processing tool to transform it into something templateish ( like "{{copyright}}" or "Copyright &copy; {{year}} {{owner}}" ) that can be easily replaced later with the actual content. If not contains the copyright note yet, would look for a suitable spot for it ( for example right before the closing </body> tag ) and insert the mentioned templateish thing.

Of course, we could suggest more suitable solution if we could see one such HTML file.

Feherke.
feherke.github.io

RE: Inserting same line of text of every web page - "link" insert?

(OP)
Hello

Thank you for replying. These files I inherited when the person who used to run the website had to give up and I offered to help (!)

Here is the text of one of the files


<?php include("/home/iomfhsi/public_html/IOMFHS/password_protect.php"); ?>
<!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=utf-8" />
<title>The Isle of Man Family History Society</title>
<link href="../../../p7spepper/wills.css" rel="stylesheet" type="text/css" />
<link href="p7pmm/p7PMMv15.css" rel="stylesheet" type="text/css" media="all" />
<style type="text/css">
</style>
<script type="text/javascript" src="p7pmm/p7PMMscripts.js"></script>
</head>
<body>
	<div id="outer">
		<div id="inner">
			<div id="masthead">
				<img name="masthead" src="../../../p7spepper/img/masthead.jpg" width="900" height="145" border="0" id="masthead" alt="Masthead Image" />			
			</div>
			<div id="contentwrapper">
					<div class="maincolumn">
						<div class="maincontent">
				
<h2>Transcript of Will of<br /></h2>
<h1>Christian Comish als Cubon, 1677 </h1>

<hr class="trans"> 
   
 
<pre>
blah blah blah transcription text
blah blah blah transcription text
blah blah blah transcription text

</pre>
<hr class="trans"> 
<p>
Submitted by:  Name of transcriber<br />
Date:  23 April 2007 <br />
Original:  LDS: 0991643 <br />
</p>

						</div>
      		</div>
      		<div class="sidebarwrapper">
        		<div class="sidebarbox">
          		<div id="p7PMM_1" class="p7PMMv15">
          		</div>
						</div>
        	</div>
      		<div class="clearfloat">&nbsp;</div>
    	</div>
   			<div class="footer">
      		<div class="footercolumn1">
        			<p>&copy; 2015 The Isle of Man Family History Society<br />Registered Charity No: 680 ISSN No: 1351-556X</p>
      		</div>
   				<div class="footercolumn2">  	
       				 <p align="right"><a href="http://www.iomfhs.im/thanks.html">Acknowledgements</a></p>
					</div>
      	</div>
  	</div>
	</div>
</body>
</html>
 

thank you for helping

____________
Pendle

RE: Inserting same line of text of every web page - "link" insert?

Hi

Ah, so they are not static HTML. And the copyright note is already there. Then I would run a command like this :

CODE --> command line

sed -i 's/&copy; 2015/\&copy; <?=date("Y")?>/' /path/to/file/* 
This will replace the currently hardcoded "2015" with PHP code that always inserts the current year.

Note that the -i option means in-place, so the files specified as parameters will be modified. Make sure you create backup copies of those 5000++ files before using that command.

Also note that if your files are organized in multiple directories, you have to take care in running the above command for each.

Feherke.
feherke.github.io

RE: Inserting same line of text of every web page - "link" insert?

Consider a free tool like grepwin, which can do a find/replace on many files, even within directories.

https://tools.stefankueng.com/grepWin.html

Quote (feherke)

Make sure you create backup copies of those 5000++ files before using that command.

No guts, no glory. bigsmile

RE: Inserting same line of text of every web page - "link" insert?

(OP)
Thank you, I'll give that a go.

thank you for helping

____________
Pendle

RE: Inserting same line of text of every web page - "link" insert?

To extend feherke's sed solution

you could use find and sed combined as a one line shell command


CODE --> shell

find . -type f -iname "*.php" -exec sed -i 's/&copy; 2015/\&copy; <?=date("Y")?>/' {} + 



Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close