 |

02-18-2005, 12:43 PM
|
 |
WebProWorld Pro
|
|
Join Date: Feb 2004
Location: Kingston, NY USA
Posts: 107
|
|
dynamically linked style sheets?
Hi. I've never worked in anything but regular html, and would like to find out if the following system could be made to work using a dynamic programming method ( php, asp, etc. ). (I don't know much at all about dynamic programing, except that information is stored on a database on the webserver, and used to create webpages automatically depending on how the link called them up - whatever exactly that means!)
We'd like to have a way for many different websites (let's call them 'A', 'B', 'C', etc.) to link to our website (let's call it 'Z'). The links would be fashioned so that a page from our website, 'Zpg1' for example, would open into a new target window (let's call that '_Zwindow').
Depending on which website (A,B,C, etc) called up '_Zwindow', we'd like 'Zpg1' to display using a unique style sheet - 'Astyle.css', 'Bstyle.css', etc. In other words, we'd like the pages from our website to look a bit different depending on whether they were linked to from 'A', 'B', 'C' etc, accordingly.
Then, if 'Zpg1' has links to 'Zpg2', 'Zpg3', etc [all still keeping focus in '_Zwindow'] can we use dynamic programing to make the correct style - 'Astyle.css' (or 'Bstyle.css' or 'Cstyle.css' etc) - persist onto pages 'Zpg2', 'Zpg3', etc, "automatically", without having to write a different file for each version ('Zpg2styleA', 'Zpg2styleB', etc, etc, etc!)?
Would dynamic programing allow us to do that? Do it easily? Please excuse my ignorance on this matter; finding out if this can be done would be very helpful to me! Thanks, all. I'm looking forward to your responces.
- Paul
|

02-24-2005, 05:43 AM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Jul 2003
Location: UK
Posts: 2,803
|
|
Assigning stylesheets dynamically
Whilst I can't get my head around exactly what you're trying to do... the answer is Yes, you can assign stylesheets dynamically.
You would need to add a variable of some description to the page link. A receiving page would have conditional statement that would recognise the 'requested' variable and assign the appropriate stylesheet.
Paul
|

02-24-2005, 10:02 AM
|
 |
WebProWorld Veteran
|
|
Join Date: Feb 2005
Location: Forchheim, Germany
Posts: 947
|
|
You can do that even with simple SSI commands:
Code:
<link rel="stylesheet" media="all" href="/src/sitea.css" type="text/css">
<link rel="stylesheet" media="all" href="/src/siteb.css" type="text/css">
where "sitea" and "siteb" need only be discriminating parts of the refering domain, like "florida" for all sites that have "florida" somewhere in the domain name.
I'm afraid it only works on Apache et al, since IIS supports only a very limited subset of SSI.
SSI can do much more than just include files. A simple introduction can be found at
http://library.thinkquest.org/15074/ssimain.html
if you need more, just google for SSI tutorial ...
Have fun.
Alex
|

02-24-2005, 11:04 AM
|
|
WebProWorld Veteran
|
|
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 862
|
|
A word of warning if you're using HTTP_REFERER, Norton Internet Security blocks the transmission of this information by default, some other firewalls might as well.
Therefore you need to deal with the case of your pages being requested with no referer information.
It would be better to pass an id to the page in the URL and use PHP to select the style sheet, as Paul said.
|

02-24-2005, 11:37 AM
|
 |
WebProWorld Veteran
|
|
Join Date: Feb 2005
Location: Forchheim, Germany
Posts: 947
|
|
ROTFL
Nope! LOL! ROFL!
Do you *really* believe NS is able to interfere with code running on my SERVER??? You must be kidding.
Norton Security will *never* see it. Why do you think this is called SERVER Side Includes??
None of that code ever reaches a browser - its all done by the server, just like writing a program in PHP, PERL, PYTHON or whatever.
How about reading
Apache Tutorial: Introduction to Server Side Includes
http://httpd.apache.org/docs/howto/ssi.html
FIRST?
Alex
|

02-24-2005, 12:37 PM
|
 |
WebProWorld Pro
|
|
Join Date: Feb 2004
Location: Kingston, NY USA
Posts: 107
|
|
Thanks, all. While I'm afraid that I don't understand quite all of the details that you've spelled out, It's good to know that there seem to be ways to accomplish what I want. If we actually decide to go ahead and set this up, I'll be working with someone who understands dynamic programming better than I do, and your suggestions will be helpful to them. Don't hesitate to further debate the different ways of doing this; it's very helpful.
Again, thanks for your replies!
|

02-24-2005, 01:00 PM
|
|
WebProWorld Veteran
|
|
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 862
|
|
Re: ROTFL
Quote:
|
Originally Posted by faglork
Nope! LOL! ROFL!
Do you *really* believe NS is able to interfere with code running on my SERVER??? You must be kidding.
Norton Security will *never* see it. Why do you think this is called SERVER Side Includes??
None of that code ever reaches a browser - its all done by the server, just like writing a program in PHP, PERL, PYTHON or whatever.
How about reading
Apache Tutorial: Introduction to Server Side Includes
http://httpd.apache.org/docs/howto/ssi.html
FIRST?
Alex
|
Glad to give you a laugh, but I obviously didn't make myself clear, and yes you are quite right Norton etc can't interfere with the code running on the server.
My understanding of what was wanted is that the visitor clicks a link on the some site and a window pops up with the page plus custom CSS served from homealone's server.
When the user clicks the link, the browser now requests the page (with custom CSS) from hommealone's server. The browser sends the referrer field to hommealone's server along with this request, which is what will decide the CSS file to use.
Because the browser asked for the page and the browser is running on the client PC with Norton the referrer field can be stripped. If you don't believe me try it!
If on the other hand the server queries homealone’s site for the page and then passes that back to the visitor/browser then we have server to server communications which will bypass anything on the client PC.
|

02-24-2005, 01:16 PM
|
 |
WebProWorld Pro
|
|
Join Date: Feb 2004
Location: Kingston, NY USA
Posts: 107
|
|
speed,
Your understanding of how we need the links and pages to work is correct. My biggest question is not whether we can get the 1st window (requested by the link on the 'other' website) to show with the css that we want, but rather can subsequent pages from our server - called by links within the page in the new window (that is, the 1st page from our site) - also show with the same (variable) css sheet that the 1st page displayed?
It seems that you guys think that it can, right?
Thanks again,
- Paul
|

02-24-2005, 01:39 PM
|
|
WebProWorld Veteran
|
|
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 862
|
|
homealone,
Yes you can do what you want, my only comment would be don't use the referrer information as I still stand by the fact that it can be blocked but instead pass an id and/or use cookies.
If you used the id method then you would simply pass it between the pages as the visitor navigated, or with a cookie you'd set it when the visitor arrived at the 1st page of your site then as they go page to page check the contents of it to select the style sheet.
Cookies of course can be blocked by visitors, so you’d still need some fallback system so that the pages can be viewed with a default style sheet, although PHP does has a method of using a parameter in the link if cookies aren't active.
|

02-24-2005, 02:27 PM
|
 |
WebProWorld Veteran
|
|
Join Date: Feb 2005
Location: Forchheim, Germany
Posts: 947
|
|
Quote:
|
Because the browser asked for the page and the browser is running on the client PC with Norton the referrer field can be stripped. If you don't believe me try it!
|
I believe you. It is clear now what you wanted to say.
What about setting a server environment variable? AFAIK those are session-persistent - please correct me if I'm wrong. I admit, I haven't tried that, but something along
Code:
*then set the variable REFSITE to "sitea"*
should work fine.
Link, of course, must now be www.yourdomain.com?id=x
when you do not want to use the referer. (Or does NS strip query strings as well?)
In the following pages you just test for this variable and include the stylesheet accordingly.
(Ha, sounds nice. I got to try that for myself ...)
Another way to solve it could be with a conditional mod_rewrite and different domains/subdomains pointing to the same virtual host, which you then could extract by querying the hostname environment variable with PHP/SSI/CGI or whatever and setting the CSS accordingly.
hth,
Alex
|

02-24-2005, 03:03 PM
|
|
WebProWorld Veteran
|
|
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 862
|
|
Yes passing an id and getting it with the query string should be fine, as NS leaves those alone.
The mod_rewrite solution should also work as again it doesn't rely on the referer data.
|

02-24-2005, 03:33 PM
|
 |
WebProWorld Pro
|
|
Join Date: Feb 2004
Location: Kingston, NY USA
Posts: 107
|
|
Yes indeed! You and speed have both been extremely helpful with this question, and I appreciate it very much. Thanks!
- Paul
|

02-24-2005, 05:20 PM
|
 |
WebProWorld Pro
|
|
Join Date: Nov 2003
Location: Northern Texas
Posts: 259
|
|
Simply because hommealone also mentioned ASP, here's a quick and simple way to pull it off.
the Querystring on the referring site (SiteA):
Code:
<a href="hommealonesSite/_Zpage.asp?ref=siteA" target="_Zpage">
ASP Code to set Correct css:
Code:
<%
'Set Variable names
dim ref
dim whichCSS
'Get referring site through query
ref = Request.QueryString("ref")
'Set CSS
if ref = "siteA" Then
whichCSS = "ZPg2StyleA.css"
ElseIf ref = "siteB" Then
'.... Keep going with this for each site you want parsed
End If
%>
<html>
<head>
... head stuff
<link rel="stylesheet" type="text/css" href="<%=whichCSS%>">
</head>
Hope that helps in some way
|

02-25-2005, 07:50 PM
|
 |
WebProWorld Pro
|
|
Join Date: Feb 2004
Location: Kingston, NY USA
Posts: 107
|
|
Thank you Jerry
Jerry,
What a very helpful posting! I really appreciate your taking the time to spell it out. Thank you so much,
- Paul
|

02-25-2005, 09:29 PM
|
 |
WebProWorld Pro
|
|
Join Date: Nov 2003
Location: Northern Texas
Posts: 259
|
|
Re: Thank you Jerry
Quote:
|
Originally Posted by hommealone
Jerry,
What a very helpful posting! I really appreciate your taking the time to spell it out. Thank you so much,
|
Paul,
Not a problem, I just post code samples the way I'd like to see them if I were the one asking for them.
Hope it helps.
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|