View Full Version : Help with php including code based on url...

07-13-2007, 02:23 PM
Hey, I have a small problem. Which comes about from much larger problems but I can't fix them, so I'm trying to work around with php. Basically, I've got two different looking sites out of 1 wordpress install with templates/css defined using categories. Unfortunately posts appearing on both sites only use the main site's css/template.

My main site: http://www.inaudible.co.uk/blog/
Secondary site: http://www.inaudible.co.uk/crocketts/ (using menu frame and http://inaudible.co.uk/blog/archive/category/crocketts/)
Cross-posted news to both sites: http://inaudible.co.uk/blog/archive/923

Now, the keen eyed of you hopefully notice that the second site uses frames, whereas the first doesn't. this may change but it helps demonstrate the problem for now.

Site 1 uses php to include it's own css/template/menu bars. Site 2 currently uses frames for the menu bar, and wordpress's category recognition to give most of the news page it's own css/template.

Now, problem is with the cross-posted news posts still picking up the main site's template, and therefore it's menu bar. If you go to http://www.inaudible.co.uk/crocketts/ and click on one of the first two news posts you'll see what i mean.

Basically, I need to get rid of this, and right now i have little option other than to trick the php into including different templates/css based on the url of the site. If you know a better way (like a wp 2.2, fully working multisite from 1 backend plugin) then please share. But for now...

Someone suggested this code elsewhere:

// This part reads the current URL of where we're at ...
// find out the domain:
$domain = $_SERVER['HTTP_HOST'];
// find out the path to the current file:
$path = $_SERVER['SCRIPT_NAME'];
// find out the QueryString:
$queryString = $_SERVER['QUERY_STRING'];
// put it all together:
$myurl = "http://" . $domain . $path . "?" . $queryString;

// Now, you search for crocketts
// if you find it, include menu1.php,
// otherwise, include menu2.php

if (ereg("crocketts", "$myurl")) {
include ("menu1.php");
} else {
include ("menu2.php");

now that would be great, if it weren't for the fact that, because i'm using frames, the constant "crocketts" in the url isn't recognized by the php, just the post's page url such as http://inaudible.co.uk/blog/archive/923 .

Right now the only trick I can think of is using something like $camefrom = $_SERVER['HOST_REFERER']; will allow me to change the indiviual post's css/template when, but only when, it is linked to from a url including "crocketts". Which would mostly work, given that my second site starts with a news page url including the term "crocketts". Unfortunately it would revert to the original template if then browsing from the individual news post (without the "crocketts" in url) to a page that would also normally pick up the main site's template/css.

So, finally, my question is: Is there a php variable I can use that will reference the current url in the browser windows, in my case the url of the original frameset? And if not, is there any other way of acomplishing the above?

Thanks, and hope the above ain't too confusing :p