Radical history project asks nation for way to change link.
March 22, 2008 12:47 PM Subscribe
I have a website with several hundred distinct pages. I want to make it so that I can put a link and image in the corner that I can change instantaneously across all of them. How can I?
Every few weeks, we upload a new page to our site and I want to be able to tell people who are reading different stuff on the site about the new reading. So I basically want a small ad that shows up and then links to whatever the new page is. I know I could easily put an image in the css background (that I could change and have it change across the entire website), but I don't think I can put an editable link with the image. I don't want to port the entire site over to some kind of cms system, I'd rather see if there's a simple way to do this with divs, css, or something else that the hive mind can teach me. Thanks.
p.s. I know that there are tons of html sites on the internet, but I'm not even sure of what to search for.
Every few weeks, we upload a new page to our site and I want to be able to tell people who are reading different stuff on the site about the new reading. So I basically want a small ad that shows up and then links to whatever the new page is. I know I could easily put an image in the css background (that I could change and have it change across the entire website), but I don't think I can put an editable link with the image. I don't want to port the entire site over to some kind of cms system, I'd rather see if there's a simple way to do this with divs, css, or something else that the hive mind can teach me. Thanks.
p.s. I know that there are tons of html sites on the internet, but I'm not even sure of what to search for.
Best answer: This would be very, very simple to do with a PHP include, if your server supports PHP. Basically, you make a little text file (just like an HTML file) that includes the snippet of graphic/link/text, and you put an "include" tag on all your HTML pages. If the snippet changes, the HTML page displays the new snippet automagically as visitors load your pages.
If your files are using .html extensions, you may need to do a little fiddling to get the PHP code to execute without changing the file extension. But like Jairus said, it depends on what kind of server you have and what kind of control your provider gives you.
posted by bcwinters at 12:55 PM on March 22, 2008 [1 favorite]
If your files are using .html extensions, you may need to do a little fiddling to get the PHP code to execute without changing the file extension. But like Jairus said, it depends on what kind of server you have and what kind of control your provider gives you.
posted by bcwinters at 12:55 PM on March 22, 2008 [1 favorite]
You don't need to use PHP. If Apache is set up right on your server, you can do it with a server-side include. It looks like this:
<!--#include virtual="/dir/file" -->
Your files don't have to have ".shtml" as extensions; that's all a matter of how Apache is set up. But doing the setup requires admin access.
posted by Class Goat at 1:08 PM on March 22, 2008
<!--#include virtual="/dir/file" -->
Your files don't have to have ".shtml" as extensions; that's all a matter of how Apache is set up. But doing the setup requires admin access.
posted by Class Goat at 1:08 PM on March 22, 2008
By the way, I don't think there's any way to do this without editing all your HTML files. But if you do it right, you'll only have to do that editing once. Then any common display you want to use is held in a single place, and you can change it in just that one place.
posted by Class Goat at 1:11 PM on March 22, 2008
posted by Class Goat at 1:11 PM on March 22, 2008
Yeah, your problem is exactly why most websites don't do static html anymore.
If you want to avoid server side includes for some reason, another solution would be to add a javascript include, and then put a document.write() in the include. Of course, this would not show up for browsers with JavaScript disabled.
posted by Deathalicious at 1:31 PM on March 22, 2008
If you want to avoid server side includes for some reason, another solution would be to add a javascript include, and then put a document.write() in the include. Of course, this would not show up for browsers with JavaScript disabled.
posted by Deathalicious at 1:31 PM on March 22, 2008
By the way, I don't think there's any way to do this without editing all your HTML files.
There's not, but there is a shortcut that I took once. If (and only if) all of your pages have something similar near where you want this to appear, you can do a multiple-file Find and Replace (search for batch find and replace; there are lots of utilities out there) and replace what's currently there (say, the header at the top of the page) with the SSI code.
I suggest copying the current header, plus your addition, into the included file, and that way any future changes you make to the header will also promulgate to all the pages.
(Note that by header I mean the logo and title and stuff like the AskMetafilter nav-bar at the top of this page... and NOT the html entity <header>, which isn't visible to the end-user.)
posted by SuperNova at 1:35 PM on March 22, 2008
There's not, but there is a shortcut that I took once. If (and only if) all of your pages have something similar near where you want this to appear, you can do a multiple-file Find and Replace (search for batch find and replace; there are lots of utilities out there) and replace what's currently there (say, the header at the top of the page) with the SSI code.
I suggest copying the current header, plus your addition, into the included file, and that way any future changes you make to the header will also promulgate to all the pages.
(Note that by header I mean the logo and title and stuff like the AskMetafilter nav-bar at the top of this page... and NOT the html entity <header>, which isn't visible to the end-user.)
posted by SuperNova at 1:35 PM on March 22, 2008
Yet another option:
Make a "what's new page", and basically just make a page redirectnew.html with the following code:
Then,
posted by Deathalicious at 1:37 PM on March 22, 2008
Make a "what's new page", and basically just make a page redirectnew.html with the following code:
<html> <head> <meta http-equiv="refresh" content="0; url=http://servername/directory/newpage.html"> </head> <body> <script type="text/javascript"> document.location.href="http://servername/directory/newpage.html"; </script> <a href="http://servername/directory/newpage.html">Please, click here if not redirected</a> </body> </html>Then an image with a hyperlink to redirectnew.html, and you can change the image each time you upload a new page.
Then,
posted by Deathalicious at 1:37 PM on March 22, 2008
Whoops. hope, etc.
...and obviously, you would have to go into all of those HTML files and put in <a href="redirectnew.html"><img src="newbanner.gif" /></a>.
posted by Deathalicious at 1:39 PM on March 22, 2008
...and obviously, you would have to go into all of those HTML files and put in <a href="redirectnew.html"><img src="newbanner.gif" /></a>.
posted by Deathalicious at 1:39 PM on March 22, 2008
SSI is the right approach, since it's simplest: you don't need to learn anything new other than that one #include line that Class Goat pasted above, and don't need to install anything, learn, patch or worry about security holes from anything new like PHP. SSI is also the fastest (best performing) way.
Once you have SSI turned on (if it is not already active in your Apache server), you'll find 100 time-saving ways to use it and wonder how you ever survived without.
posted by rokusan at 2:23 PM on March 22, 2008
Once you have SSI turned on (if it is not already active in your Apache server), you'll find 100 time-saving ways to use it and wonder how you ever survived without.
posted by rokusan at 2:23 PM on March 22, 2008
Response by poster: holy moley, I'm going through these answers. As a quick aside, if it effects anything, the pages are all basic html pages.
I think we're on an apache server. I tried just now to do it with the php solution, but when I worked on the htaccess page (to allow regular html pages to be have new php be visible), it made it so every page was downloaded instead of going to the browser.
posted by history is a weapon at 2:54 PM on March 22, 2008
I think we're on an apache server. I tried just now to do it with the php solution, but when I worked on the htaccess page (to allow regular html pages to be have new php be visible), it made it so every page was downloaded instead of going to the browser.
posted by history is a weapon at 2:54 PM on March 22, 2008
If you have that many pages, you should look into a Content Management System such as Joomla or Drupal.
If you really want to stick with static pages, tools such as Dreamweaver or *gack* FrontPage can help automate these types of changes.
posted by boba at 2:55 PM on March 22, 2008
If you really want to stick with static pages, tools such as Dreamweaver or *gack* FrontPage can help automate these types of changes.
posted by boba at 2:55 PM on March 22, 2008
You can use that htaccess file to enable SSI, if it's not already. PHP is overkill here.
posted by rokusan at 3:11 PM on March 22, 2008
posted by rokusan at 3:11 PM on March 22, 2008
« Older Help my software team go from good to great. | How do we stop the playground bullies? Newer »
This thread is closed to new comments.
You haven't given any details on your site, though. What server are you running? What languages does it support? What kind of access do you have to make configuration changes?
posted by Jairus at 12:54 PM on March 22, 2008