View Full Version : Help with menus and frames and stuff, wordpress related.
pepsi_max2k
07-12-2007, 12:10 AM
I think i've stumped the wordpress forum users with this so hopefully someone here can help. I won't bother with the mostly wordpress specific info but...
http://www.inaudible.co.uk/crimea/
http://www.inaudible.co.uk/crocketts/
please ignore the dual menu bar on the first, but the dual menu bar on the second (when viewing a full post, click title of one of the top 2) is what i want to get rid of.
basically i was using two frames for both sites, one with a menu bar and one with content. the content on both is from a single wordpress install, one using the main blog index with one css template and the second site using a single category with a seperate css template.
I now want to get rid of the frames (at least on the first site) and just leave a single menu bar included using php.
problem is, a few of the posts on the second site use the template from the first site when viewed on the individual post pages, so they would include the menu bar from the first site (for now, there'd still be the correct menu bar in the frame, but that would change if i got rid of the frames on that site too).
Unfortunately I've no idea how I can change stuff to either get the posts on both sites only using a specific template (don't think it's possible the way i've separated categories / templates in WP) so I wondered if there's another way to include a menu bar on a page.. .like giving some kinda php include code that will include menu code based on where a page has been linked from?
eg. i'm on page http://inaudible.co.uk/blog/archive/category/crocketts/ then click the first post entry title ( http://inaudible.co.uk/blog/archive/923 ), the entry page then realises i've come from .../crocketts/ and uses one menu bar code. alternatively if i'm at http://inaudible.co.uk/blog/ and click the same post title ( .../923) it loads a different menu because i've come from .../blog/.
If anyone knows anything about WP or how I could get thinks working a little better then please lemme know :) Thanks.
mlseim
07-12-2007, 03:19 PM
Do you know which WP file has the code for your menu.
Is it: header.php?
If you can figure out which PHP script displays that menu,
we might be able to do something where the PHP script looks
at the URL and determines whether to display it or not.
pepsi_max2k
07-12-2007, 03:21 PM
it's currently in header.php but i could take out the menu code and stick it in a seperate file, then include that in header.php if needed.
i've also just found this plugin:
http://anthologyoi.com/wordpress/plugins/super-category-multi-blog-plugin-v-08.html
which appears to do mostly everything i want in a much simpler way (though something weird about parked domains) but sods law it only works with 2.1 and i just uupgraded to 2.2 a few weeks ago, and i hear downgrading's not so fun :(
EDIT: fwiw, this is the code used on individual post pages (single.php) to include the header (there's two seperate ones, problem lies in only being able to include the crocketts one for crocketts only posts)...
<!-- If post in any cat other than crox, else if in only crox... -->
<?php
$post = $wp_query->post;
if ( in_category('1') || in_category('2') || in_category('11') || in_category('12') || in_category('13') || in_category('14') || in_category('15') || in_category('16') || in_category('17') || in_category('18') || in_category('19') ) {
include(TEMPLATEPATH . '/header.php');
} else {
include(TEMPLATEPATH . '/header-crox.php');
}
?>
mlseim
07-12-2007, 05:38 PM
List your current "header.php" file ...
I think it can be done just in there, but I'm not sure yet.
pepsi_max2k
07-12-2007, 05:47 PM
ok, everything between <!-- start menu bar.. --> and end menu bar, that can stay as it's just additional cs and js for the menu. all the <!-- MENU BAR HTML --> is the main problem.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<!-- START MENU BAR CODE -->
<!--[if IE]>
<style type="text/css">
.mainitems {
line-height: 30px;
}
.subuls {
line-height: 13px;
}
#cssdropdown ul {
margin-top: -7px;
}
</style>
<![endif]-->
<script language="Javascript">
<!--
function pic3(){
props=window.open
('site.html','1','width=440,height=500,menubar=no,scrollbars=no,toolbar=no,location=no,directories=n o,resizable=no');
}
photo5out=new Image(204,30); photo5over=new Image(204,30);
photo5out.src="/crimea/images/site/banner/crimeabannerlogo.png";
photo5over.src="/crimea/images/site/banner/crimeabannerlogoalt.png";
// -->
</script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById
("cssdropdown").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("
sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>
<!-- END MENU BAR CODE -->
<script src="http://www.inaudible.co.uk/crimea/imagescript.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
onload=function() {
document.getElementById('sidebar-left').style.height=
document.getElementById('page').offsetHeight - 10 +"px";
document.getElementById('sidebar-right').style.height=
document.getElementById('page').offsetHeight - 10 +"px";
}
//]]>
</script>
<?php wp_head(); ?>
</head>
<body>
<!-- MENU BAR HTML -->
<div class="top-menu-left"></div>
<div class="top-menu-right"></div>
<div class="top-menu">
<a href="javascript:pic3()" onMouseOver="photo5.src=photo5over.src; window.status='Click For Crimea Logos'; return true;" onMouseOut="photo5.src=photo5out.src; window.status=''; return true;"><img name="photo5" src="/crimea/images/site/banner/crimeabannerlogo.png" width="204" height="30" alt="THE CRIMEA - click for logos" id="crimea"/></A>
<div class="top-menu-content">
<div class="top-menu-content-ie">
<ul id="cssdropdown">
<li class="mainitems"><a href="/blog/">HOME</a>
</li>
<li class="mainitems"><a href="/blog/archives/">ARCHIVES</a>
<ul class="subuls" style="width: 3.3em">
<li><a href="/blog/archive/date/2007"> 2007</a></li>
<li><a href="/blog/archive/date/2006"> 2006</a></li>
<li><a href="/blog/archive/date/2005"> 2005</a></li>
<li><a href="/blog/archive/date/2004"> 2004</a></li>
<li><a href="/blog/archive/date/2003"> 2003</a></li>
<li><a href="/blog/archive/date/2002"> 2002</a></li>
</ul>
</li>
<li class="mainitems"><a href="/crimea/pages/gigs.html">GIGS</a>
<ul class="subuls" style="width: 5em">
<li><a href="http://www.last.fm/music/The+Crimea/+events">Upcoming</a></li>
<li><a
href="http://www.last.fm/music/The+Crimea/+events/past">Previous</a></li>
</ul>
</li>
<li class="mainitems"><a href="/crimea/pages/info/info.html">BAND INFO</a>
<ul class="subuls" style="width: 7.5em">
<li><a href="/crimea/pages/info/history.html">Who Are They?</a></li>
<li><a href="/crimea/pages/info/ustour/ustour.html">US Tour Diary</a></li>
<li><a href="/crimea/pages/info/reviews.html">Reviews</a></li>
<li><a href="/crimea/pages/info/press.html">Press Clippings</a></li>
<li><a href="/crimea/pages/info/diary.html">Bandography</a></li>
</ul>
</li>
<li class="mainitems"><a href="/crimea/pages/music/music.html">MUSIC INFO</a>
<ul class="subuls" style="width: 6.1em">
<li><a href="/crimea/pages/music/discography.html">Discography</a></li>
<li><a href="/crimea/pages/music/lyrics.html">Lyrics</a></li>
<li><a href="/crimea/pages/music/promos.html">Promos</a></li>
<li><a href="/crimea/pages/music/compilations.html">Compilations</a></li>
<li><a href="/crimea/pages/music/tabs.html">Guitar Tab</a></li>
</ul>
</li>
<li class="mainitems"><a href="/crimea/pages/images/images.html">IMAGES</a>
<ul class="subuls" style="width: 7.1em">
<li><a href="http://community.webshots.com/user/thecrimea">Press
Clippings</a></li>
<li><a href="http://community.webshots.com/user/pepsi_max2k">Gigs</a></li>
<li><a href="/crimea/pages/info/ustour/ustour.html">US Tour</a></li>
<li><a href="http://thecrimea.buzznet.com/user/archive.php">Official
Album</a></li>
<li><a href="/crimea/pages/images/pictures32.html">John Bown</a></li>
</ul>
</li>
<li class="mainitems"><a href="/crimea/pages/downloads.html">DOWNLOADS</a>
</li>
<li class="mainitems"><a
href="http://www.corporationrecords.com/store/index/27">SHOP</a>
</li>
<li class="mainitems"><a href="/crimea/pages/links/links.html">LINKS</a>
<ul class="subuls" style="width: 6.1em">
<li><a href="/crimea/pages/links/links1.html">General</a></li>
<li><a href="/crimea/pages/links/links2.html">Reviews</a></li>
<li><a href="/crimea/pages/links/links3.html">Forums</a></li>
<li><a href="/crimea/pages/links/links4.html">Other Links</a></li>
<li><a href="/crimea/pages/links/links5.html">Other Bands</a></li>
</ul>
</li>
<li class="mainitems"><a href="http://www.b2g2.com/boards/board.cgi?
user=thecrimea">MESSAGES</a>
</li>
</ul>
</div>
</div>
</div>
<!-- END MENU HTML -->
<!-- CLEAR TO LEFT -->
<div id="restofcontent">
<div id="showimage"></div>
<div id="videoBar-player"></div>
<div id="page">
<hr />
mlseim
07-12-2007, 06:07 PM
OK ... make a backup copy of "header.php" (so you don't lose the original).
First of all, remove everything between and including:
<!-- MENU BAR HTML --> and <!-- END MENU HTML -->
Save it as "menu1.php"
Duplicate it for another menu and save it as "menu2.php"
Then, see the PHP script below where we first load a variable with the URL,
then later, check the URL for "crocketts". If it sees that, include
"menu1.php", otherwise, include "menu2.php".
<?php
// 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;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<title><?php bloginfo('name'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<!-- START MENU BAR CODE -->
<!--[if IE]>
<style type="text/css">
.mainitems {
line-height: 30px;
}
.subuls {
line-height: 13px;
}
#cssdropdown ul {
margin-top: -7px;
}
</style>
<![endif]-->
<script language="Javascript">
<!--
function pic3(){
props=window.open
('site.html','1','width=440,height=500,menubar=no,scrollbars=no,toolbar=no,location=no,directories=n o,resizable=no');
}
photo5out=new Image(204,30); photo5over=new Image(204,30);
photo5out.src="/crimea/images/site/banner/crimeabannerlogo.png";
photo5over.src="/crimea/images/site/banner/crimeabannerlogoalt.png";
// -->
</script>
<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
var sfEls = document.getElementById
("cssdropdown").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("
sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>
<!-- END MENU BAR CODE -->
<script src="http://www.inaudible.co.uk/crimea/imagescript.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
onload=function() {
document.getElementById('sidebar-left').style.height=
document.getElementById('page').offsetHeight - 10 +"px";
document.getElementById('sidebar-right').style.height=
document.getElementById('page').offsetHeight - 10 +"px";
}
//]]>
</script>
<?php wp_head(); ?>
</head>
<body>
<?php
// 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");
}
?>
<!-- CLEAR TO LEFT -->
<div id="restofcontent">
<div id="showimage"></div>
<div id="videoBar-player"></div>
<div id="page">
<hr />
pepsi_max2k
07-12-2007, 06:21 PM
ok i think i follow you but i see a slight problem...
reason i'm adding menu bar in to each page instead of using frames is so i can just go to http://www.inaudible.co.uk/blog/ and get a full news page w/ menu included. this page'll either be redirected to by .../crimea/ or a separate domain name.
my other site, http://inaudible.co.uk/crocketts/ using frames, is actually a menu frame and http://inaudible.co.uk/blog/archive/category/crocketts/ .
an individual post like http://inaudible.co.uk/blog/archive/923 can be linked to by both sites.
now, problem i see is, if i view an individual post from /blog, fine, it'll have the normal menu2.php code on (THE CRIMEA...).
If I view it from /crocketts, at the moment although the frameset gives it the inaudible.co.uk/crocketts url, i'm still just viewing http://inaudible.co.uk/blog/archive/923 and isn't gonna change the menu bar at all, unless it somehow is just referencing the url of the frameset or the url it's just been linked from. so back to square one :(
the more i think about it the less i think it's actually possible at all, as long as i have identical urls for individual posts on both sites. :(
mlseim
07-12-2007, 06:37 PM
oh lordy ... this is confusing ....
All I can say is try it and see what happens.
I can't follow the frame thing in my head.
make "menu1.php" nothing ....
like this:
<!-- nothing -->
make "menu2.php" your existing menu code
see what happens with the menu ....
If things appear backwards, you can switch the two
lines around:
<?php
// Now, you search for crocketts
// if you find it, include menu1.php,
// otherwise, include menu2.php
if (ereg("crocketts", "$myurl")) {
include ("menu2.php");
} else {
include ("menu1.php");
}
?>
pepsi_max2k
07-12-2007, 06:56 PM
ok i've gotta go out for a bit so i'll try in a bit, but i'll explain the frame thing incase it helps...
forget the frames. one worpress install, inaudible.co.uk/blog , used for posts about one band. i add posts about a second band to a specific category, with a seperate stylesheet and template for that category, all under http://inaudible.co.uk/blog/archive/category/crocketts/ . that way i can cross-post things to both the root blog and the crocketts category, but those posts won't use the crocketts specific stylesheet or template, and have the same url when accessed from either site. so, menu bar added to root ends up on posts linked to from /crocketts.
hope that makes more sense :thumbsup: and i hope i'm wrong thinking your code wont work :p
pepsi_max2k
07-12-2007, 08:00 PM
ok the result is what i thought would happen, all pages and posts using the root template contain the original menu code, all those under purely the crocketts category / site use the crocketts template which avoids the menu code altogether :( end result being it's exactly the same as before.
sooo... anyone know an up to date plugin for 2.2 that allows multiple sites to be born from one WP install / db / user panel? :rolleyes:
edit: a possible (but not great) solution... i'm planning on using a new domain name, immortalsoon.co.uk to direct to the inaudible.co.uk/blog/ page. i don't quite know how they work yet, but i think i can make users accessing immortalsoon.co.uk end up on that page re-direct style, but also have them never see the inaudible.co.uk name.
if that works then i can then redirect inaudible.co.uk/crimea to immortalsoon.co.uk, then all users viewing the crimea site end up with an immortalsoon address and i can then use that to add the correct menu code, and use the inaudible.co.uk address to serve up the crocketts menu code as they shouldn't be seing inaudible at all on the crimea site, and shouldn't be seing immortalsoon on the crocketts site....
bit of a stupid solution but it might work...
edit 2 : am i describing an add-on domain? hmmm...
mlseim
07-12-2007, 08:36 PM
What is the purpose of frames in the first place?
Why couldn't you use PHP instead of frames.
See my test page using PHP includes .... and no frames!
http://www.catpin.com/crocketts.php
Here's the PHP for that test page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is my test page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<?php
// Get page
$url = "http://inaudible.co.uk/blog/archive/category/crocketts/";
$data = implode("", file($url));
echo $data;
?>
</body>
</html>
That's why I'm so confused about the frames issue.
People use frames and I don't know why.
EDIT: More thinking on this ...
Perhaps in your case, it might be best to point the domain to the other site,
(domain forwarding). This would then eliminate the frame and all links would
stay within the domain name .... (don't know if I explained that very good).
In my example, the domain name doesn't match yours, so the links leave my site.
If I use domain forwarding, either domain name would work the same, so the links
wouldn't matter ... they would go to the same pages. oh my .... now i'm confused again.
Well .... maybe with all of this discussion, some great idea will pop into someone's head
and they'll offer the ultimate solution. I don't know if I can muster a good solution.
.
pepsi_max2k
07-12-2007, 09:02 PM
the frames are from way back (7 odd years ago) before i even knew what php was...
you'll probably just have to browse around the site to see that the problem is. the frames are used to tie together .co.uk/blog/category/files.html, .co.uk/blog/post/files.html and .co.uk/crocketts/files.html into one site,
while using a seperate frameset to tie together .co.uk/blog/files.html, .co.uk/blog/post/files.html and .co.uk/crimea/files.html,
and the problem arises with both accessing .co.uk/blog/post/files.html and me having no way to alter the css/template of those pages, to add seperate menu bars without a frameset, so i was using all pages without menu bars and adding the menu bar in a frame.
from what i can see in your code i'm sure it still wouldn't solve the problem, and i think i'm just confusing everyone now so i'll give this thread up :( hopefully the domain based workaround will have better results :)
mlseim
07-12-2007, 09:11 PM
I agree, get the domain stuff put together.
pepsi_max2k
07-13-2007, 02:05 PM
yesterday = worst web coding day ever. today = hopefully better.
you wont believe it, but i also found out that not only does the php stuff you suggested, or old plugins that would allow me to do things seperately not work, i also found out that i can't even do the seperate domain name trick as the host i have it with won't allow name server changes (well, it was free...) :'(
but i think i've found yet another workaround.
$camefrom = $_SERVER['HTTP_REFERER'];
unless something else goes wrong, then using that with some other code means accessing the page http://inaudible.co.uk/blog/archive/923 from /blog means /blog's template/css, accessing it from anything with the name "crocketts" in means crocketts template/css/menubar :d
'course, navingating to other pages from that page means i have the original problem, but hopefully there's few enough visitors to my crocketts site never to really notice it. now i'm off to find some php gurus to see if there's any other tricks that could be used.
ps. don't think i said thanks for the help above, so .. thanks :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.