Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using #include to update many sites

Status
Not open for further replies.

CWebster

Programmer
Jun 12, 2002
38
GB
I run several sites who all use the same advertisers. Changing the adverts around on all of these sites at the end of every advertising deal is quite time-consuming so I'm looking for an easier way of doing it.

What I really want to be able to do is create one file for each banner and only edit and upload this file when the banner changes. This change would then be reflected on all of my sites.

I've tried using SSI but - apparently - this won't work because it can't access remote files, only those in the same directory (I've tried this and it seems true). I thought that PHP was the answer but this didn't seem to work either (although, admittedly, I know virtually zip about PHP so I could be going wrong somewhere..) and JavaScript was only giving me error messages.

Is it possible that I'm doing one of the above methods incorrectly or is there an easier solution? Ideally, I wouldn't have to change the filename of each page from .HTML to whatever.

Thanks in advance.

Colin
 
try using

Code:
<!-- #INCLUDE VIRTUAL=&quot;banner.js&quot; -->
The secret of life is honesty and fair dealing. If you can fake that, you've got it made.
Groucho Marx (1895-1977)
 
Hi mate,

You cannot use SSI, but what you said about the same directory is incorrect, SSI can include anything under your Directory root.

You could use javascript, PHP, Perl, etc to do this and there are loads of free scripts out there.

Take a look at the following site:


Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Cheech,

That will not work because for security reasons, SSI can only include files under your Directory root.

Also the correct syntax for the directive is

<!--#include virtual=&quot;file.shtml&quot; -->

There is also no need to run a js file through an SSI directive, js should be called by the <script> directive and not by SSI.

<SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT' src='file.js'></SCRIPT>

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Thanks for your help guys.

I actually used JavaScript in the end - managed to get it working. I don't know what I was doing wrong yesterday when I attempted this - perhaps because I didn't stick all of the JavaScript on the same line..?

anyhow, Cheers!
 
Hi mate,

One common error when using an external js file is to add

<script>
</script>

tags to the file, always check this first as I have seen a lot of people looking for a more advanced problem when the solution was in front of them the whole time.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Hey CWebster...I'd like to learn how to do this too. Can you enlighten me?

Thanks. -----------------------------------------------
These are endless galaxies which are yours.
You can journey to infinity
through the endless passages of the cosmos.
Even better. This all belongs to you.
This is your mind.
 
Hi BDNFLNC,

This is what I did in the end:

Firstly, I created the JavaScript file that contained one of the banners. This is all that this .js file contains:
__________________________________
document.write(&quot;<a href= +
&quot;<img src= &quot; +
&quot;width=468 height=60 border=0 alt=Some Alt Text></a>&quot;)
__________________________________
It seems to be important to keep it all on one line (or, as in the case above, use the + sign at the end of each line to break it down a little). Also, I don't think you can use quotation marks other than the ones you can see above.

Let's say I saved the above file as banner.js and placed it into
To link to this file, all I have to place on a page is:
__________________________________
<script language=&quot;JavaScript&quot; src=&quot;__________________________________

Now, when I change over my advertisers, all I have to do is edit the original banner.js file.

I hope that makes sense to you!

Colin
 
*g* Maybe I'm missing something. It sounds like ssi is perfect for cwebster. Let's see, cwebster has lots of advetizers and wants to have one banner file for each advertizer and change that one file (per adv) so the changes are then site wide. That is what ssi is best at.

I use ssi everyday. You can access almost any file on your server with ssi. I usually create a directory I call &quot;include&quot; in the root, and place the include files there. Let's remember what we refer to as root can mean different things to a person on a vertual server and different to someone on a dedicated server.
I also use ssi to call perl scripts. It is just like being able to put perl into a html document. Here is a link to a site that is built almost entirely using ssi to dymanically generate almost every single page on the site. It is so totally cool!
I've noticed that when I teach ssi, one of the most confusing aspects is getting the correct path to the include or script. Also there is usually some confusion as to why use a virtual include verses a file include.

mike
 
Well Wullie that is not quite true. You can call perl scripts that read a perl script from another server and then read any file or files on a remote server. What you do is call a perl script that opens a file and then prints that file to the browser. Intead of bing displayed in the browser, it will be read by the calling script. I can post the perl code for anyone interested in this technique. It is not your average ssi coding, but it works like a charm.

mike
 
Just a follow up. What cwebster would need to do is create a perl script that reads all the necessary values from as many severs as necessary. Then the information is passed to the correct folders on the parent server. Then the various includes will read the correct information. This can be done with one simple script. Then the calling script inserts the results via na include.

Here is the structure.

an include calls a perl script that updates all the parent include folders or files.

Then the same calling script inserts the correct html into the resident document.

While this technique is definantly advanced coding, it can be done.


mike
 
Hi mate,

As I said above, Perl can do this. What you are suggesting is what I meant above when saying that the server side languages would work, but it is not SSI that would be used to actually include the files, but rather a Perl script called by an SSI exec directive.

I use SSI extensivly on my site, everything from including files right through to server side browser checks and also the option to change the sites colour schemes. I like SSI but in this case SSI is not the best option for the job.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Wullie,

Maybe I don't understand what cwebster wants to do. If cwebster has includes on A server and wants to update them with information from B, C and D servers, then ssi is the best to go.

Have you ever called a script via an include to update, on a parent server, multiple includes from multiple severs? I have or I wouldn't have suggested it. The wonderful thing about coding, is there is always more than one to do something. Having one file to update multiple files is almost always the best way to go.

I'm not sure why you suggest that ssi isn't doing the work. Yes, perl would be grabbing the information, but it is only doing the same thing that any other use of ssi include command, and that is to insert into a document information. Does it really matter whether perl is gathering the info, or whether it is a HTML file, or a text file, ssi is the vehicle to insert the info into the document.

Also, using the exec command is not necessary to execute perl scripts. I have done what I suggest lots of times and it works just fine. It is much better than using JavaScript. Code once, update site wide.

We can agree to disagree.

mike
 
Mike,

The point I was trying to make is that he only needs to use the following code once in one single file:

document.write(&quot;<a href= +
&quot;<img src= &quot; +
&quot;width=468 height=60 border=0 alt=Some Alt Text></a>&quot;)


then on each page he has the following:

<script language=&quot;JavaScript&quot; src=&quot;
This is a lot easier and a lot less code than using a SSI directive on each page and then a perl script on each server interacting with each other to do this job.

There is no point giving a solution that is harder to implement than one he has already.

Personally, I would use SSI and Perl, but that is because I try to keep as much as possible server side and also because I know how to do it, then again this is not for me or you.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top