Gossamer Forum
Home : Products : DBMan : Customization :

site templates in dbman

Quote Reply
site templates in dbman
I am using DBman on my clients server where he has a whole bunch of virtual hosts. He is marketing pre-fab realestate websites and they include their own database. Each owner has the ability to add/delete/modify their listings in their own database (each database is separate from one another). There are 10 website styles to choose from so I can't just have 1 html.pl. I am including a header/footer on my own version of dbman but I'm only using 1 interface, not 10 (the call to header/footer is in the db.cgi). I would like to place a header/footer in the persons home directory and have the dbman look for the file and plug it in where appropriate. Doing something like this would save me tons of time 'cuz I wouldn't have to edit the html.pl that much each time (I'd just change the header/footer path instead of adding the entire thing to the html.pl). Each site already gets their own html.pl, .db file etc. I just want to save as much time as possible by being able to access a pre-fab header/footer in the users directory.

Does this all make sense? If it doesn't, just let me know. Any ideas are appreciated. If you want to see an example of these sites, let me know and I can post a url.

Thanks!


------------------
Jason
Extreme mtb
extreme.nas.net

[This message has been edited by jdulberg (edited June 17, 1999).]
Quote Reply
Re: site templates in dbman In reply to
I *think* I'm following you, but correct me if I'm wrong. Each client has their own html.pl, but you've already sorted that bit out yes? You just want to have a common header and footer bit, that will work like server-side includes?

adam
Quote Reply
Re: site templates in dbman In reply to
I'll clarify a bit.

A person who buys one of these pre-fab sites has a choice of 10 designs. I then add their info (name, photo, customized logo etc.) to the site and upload it to the server. Have a look at realestate-webpages.com and go to the view websites link to see what I mean. You are right with the SSI thing but I need a way to do it without editing the db.cgi 'cuz I don't copy that to everyone's directory. So there would need to be something in the db.cgi that figures out what header/footer is needed and plugs it in accordingly. Each virtual host has a name like VH002, VH003 etc. and the html.pl, .cfg are going to reside in the main cgi directory and will be named something like VH003-html.pl VH003.cfg etc., etc. The virtual hosts are aliased so they look to the realestate-webpages cgi-bin instead of their own.

Does that make a bit more sense? Let me know if you need more info.

Thanks again!


------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
jdulberg,

As a starter, take a look at the following web page http://www.gossamer-threads.com/...m12/HTML/000191.html

(It refers to linking footer and header files!)

Regards,



------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: site templates in dbman In reply to
Thanks for the suggestion. I am already using the header/footer thing on my own website but what I would like to do in this instance is a little more in-depth than what I have done already (I think).

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
Are you using the "user-friendly html.pl" mod? There are subroutines for headers and footers in there. Is there a reason you couldn't just use them?

If not, you could just read text files with all the html coding in them into the page from the html.pl file.

Unless I'm completely missing the point. Smile

------------------
JPD





Quote Reply
Re: site templates in dbman In reply to
Jason,

Ah, I think I getcha now. Well, it seems a little OTT, but you could set up a subroutine in db.cgi to parse the URL, get the users home directory and set that as the include dir, and then parse the header and footer files I guess.

Something like this?:

Code:
sub get_header_footer {
%users = (
"domain1.com" => "paul",
"domain2.com" => "john",
"domain3.com" => "mick"
);
$home_dir = "/server/path/to/users/dirs";
$this_domain = $ENV{'SERVER_NAME'};
while (($domain,$user) = each %users) {
if ($domain eq $this_domain) {
$this_user = $user;
}
}
$users_dir = "$home_dir/$this_user";
$header = "$users_dir/header.txt";
$footer = "$users_dir/footer.txt";
}

What this is doing is checking the requested domain name, comparing it to a hash of domains on the server, and if it gets a match it then know which dir to use for the user, and where to find the files. Obviously there's no error checking or anything.

I won't go any further until you confirm that this is the kind of thing you need, but after that, you could put the data from the header and footer files and put them in $header_html and $footer_html variables, which you could then slap into your html.pl files.

Is that what you mean?

adam

[This message has been edited by dahamsta (edited June 18, 1999).]
Quote Reply
Re: site templates in dbman In reply to
That's the kind of thing that I'm looking for dahamsta. Basically, when I upload a new website for a realtor (I'm going to be uploading at least 1000 of 'em), I want to do it as fast as possible. If I have to put the HTML into each html.pl, it'll take far too long to do. I only want to use 1 db.cgi so if I make any changes, I don't have to do it 1000 times.

Does that clear things up at all? Let me know if you need any more info. I really appreciate your help!!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
Here's some more info:

Alex did the install of the dbman for my client and he put in something that will detect the host that is calling the db.cgi and will then use the appropriate html.pl, .cfg file etc. I have posted what he has done to the .cfg file to get that working if you want to see it:
realestate-webpages.com/temp/default.cfg.txt

I am not sure if it is possible, but couldn't I just add something to what Alex has done to the cfg file for the headers and footers. The only possible problem with that is that he is using the hostname to detect and I have the path's to the virtual hosts listed as VH001, VH002 etc. - not the hostname.

I hope this helps out a bit more. Let me know if you need anything else.

Thanks again!!!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
In looking at the code that you made for me dahamsta, I'm thinking that it would work. Would it be possible to adapt that to what Alex has done? We're getting close here... I know it.

Thanks again.

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
Hi Jason,

Sorry, I haven't been around for a couple days. I'm working on a fairly large portal at the moment, and that tosser tachus got on my wick. I nearly didn't come back, but I said why should a langer like that eff it up for everyone else. I'll have a look at your files tomorrow and see if something can be set up for your situation...

adam
Quote Reply
Re: site templates in dbman In reply to
Whenever you get a chance is cool with me. I appreciate your help!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
I just thought of something that may work and I was wondering if anyone could help me out. In the .cfg file, Alex made a thing that will detect what host is accessing the db and will plug the appropriate html.pl etc into the script path etc. So it looks something like this:

Code:
# Full Path and File name of the database file.
$db_file_name = $db_script_path ."/data/$host.db";

So for the header/footer, could I not just add another line that will plug the header/footer data into the SSI call in the db.cgi.?? So maybe it would look like

Code:
#header
$db_header = $db_script_path . "/data/$host.header.inc";

#footer
$db_footer = $db_script_path . "/data/$host.footer.inc";

Then the ssi call in db.cgi have something like:

Code:
#header
open (INCL, "$db_header") or die "Can't: $!";
$inc = join ("", <INCL> );
close INCL;

Would this idea work or am I over my head here? Basically, if I only need to have 1 html.pl - that would be tons easier and would take up far less space than having hundreds of html.pl's. All I'd do is have the header/footer for each site in a data directory.

Please let me know if this would work or if anyone has any ideas for something that would work (I'm just guessing at what I have), I'd really, really appreciate it!!

Thanks again and sorry to bug everyone about this!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
I really don't know about using SSI. With any luck someone else will have an answer for you.

One thing I would suggest, though, if you think it might work, give it a shot. I don't think there's anything that you can do which could cause permanent damage to anything.

------------------
JPD





Quote Reply
Re: site templates in dbman In reply to
Okay, I tried what I said but it returns a "1" where the call to the sub in the db.cgi.

Here's what I have in the .cfg file:

Code:
#header
$db_header = $db_script_path . "/data/realestate-webpages.com.header.inc";

realestate-webpages.com will be replaced with $host when I put it online.

Here's the db.cgi

Code:
sub inc_header{
#header
open (INCL, "$db_header") or die "Can't: $!";
$inc = join ("", <INCL> );
close INCL;
}

and here's the html.pl

Code:
print &inc_header;

Any ideas on what could be causing the problem?

Thanks!!

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
In reference to your SSI question:

The web server doesn't parse cgi output for SSI. You can download a module and load it at the server that will allow it, I forget the name right off hand, but it puts a big performance hit on the server. What I would suggest is simply telling it to include a certain file's contents using perl like you wanted to.
Quote Reply
Re: site templates in dbman In reply to
Sorry, I meant to include a file using cgi and not SSI like I mentioned. I posted the CGI that I'm using on this message thread. Sorry to be a bit confusing.

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
Just a guess but would you want a
return $inc;
line in that subroutine?
Quote Reply
Re: site templates in dbman In reply to
Does anyone have any ideas why this subroutine would put a "1" where the header and footer are supposed to go? It looks like it should work but I'm probably just forgetting something.

Sorry to bug people.

------------------
Jason
Extreme mtb
http://extreme.nas.net
Quote Reply
Re: site templates in dbman In reply to
I'm not quite sure. I got that include subroutine from the following thread:

gossamer-threads.com/scripts/forum/resources/Forum3/HTML/000403.html

Am I doing what Alex has correctly?

Thanks for your help!

------------------
Jason
Extreme mtb
http://extreme.nas.net