I've been working on customizing a theme From TNThemes. Which are excellent BTW (so is their service).

What I did was adjust how the Primary Links work and made them have their own Image Backgrounds as tabs. I got it all working beautifully on my Dev site. However, when I loaded the new theme to my live site and changed over, the Tabs Print way off to the right of the screen and the CSS background image prints itself on top of the actual tab image.

My Dev site - www.nlighttest.com/myforeskin.org (Check to see what it's actually supposed to look like)
My Working site - www.mfcommunity.org
Test User: DrupalTest
Password: test1
-I've set up a test account with the same theme loaded. As you can see... the issue is very strange and even has my Rep at TNT stumped.
-Please don't create any content as this is a live site.

I Don't Know what code I should post here for you - so if you can help, then please let me know what code you need to see and i'll gladly post it for you to review.

Thanks a ton,
Richard

Comments

nevets’s picture

Take a look at the html generated, from the dev site you have

<div id="header-bottom">
<ul class="primary-links">
<li id="Community">

but from the live site

<div id="primary-menu">
<ul class="links">
<li class="menu-364 active-trail first active">

so it looks more like a coding/theming issue.

marcvangend’s picture

I'm sorry to say this, but IMHO, the theme (or at least the output) is quite a mess. Your dev site doesn't look good either. For one thing, the html is not valid. I noticed that the results in Opera, Firefox and IE are very different from each other. That is often caused by invalid html, because browsers have their own way of making the best they can from invalid code.
I also see things like position:absolute and font-size:1px, which is valid css, but is often used as a quick way of fixing problems that really should be fixed in another way. It makes debugging this kind of problems very difficult for me.

Jeff Burnz’s picture

I dont think the validation has much to do with this, for html it only fails on a few comments syntax and the CSS has some validation issues but nothing to crazy as far as I looked.

Anyway, I was able to fix this for Firefox in about 5 minutes, perhaps TNT will give me a job in tech support now :) (actually that would be great).

You need to totally change how this is being done, and of course I have no way of testing this in anything but Firefox.

BTW, this is the page I worked on, hope its the right site (they both looked messed up) http://www.nlighttest.com/myforeskin.org/content/info-center

local.css (line 64)
#header-bottom {
left:35px;
position:absolute;
top:92px;
}

local.css (line 70)
ul.primary-links {
font-family:sans-serif,"Lucida Grande",Verdana,Arial;
list-style-image:none;
list-style-position:outside;
list-style-type:none;
margin:0;
padding:0;
}

local.css (line 79)
ul.primary-links li {
float:left;
margin:0 1px;
}

local.css (line 98)
li#Community a {
background:transparent url(images/icons/community.png) no-repeat scroll left top;
}

local.css (line 91)
li#Community a, li#Marketplace a, li#Info_Center a {
color:transparent;
}

local.css (line 84)
ul.primary-links li a {
display:inline-block;
height:40px;
width:300px;
}
foodin65’s picture

Thank you so much for your help. I'm actually a total newb at this. I totally customized parts of the TNT Theme. I updated the CSS to match and it's much closer now, but the CSS hover isn't working. It's not showing just the top third of the image like it's supposed to. It's showing the entire image.

Here's the CSS:

/***********************/
/* Primary Links Images*/
/***********************/
#primary-menu ul.links li.first,
#primary-menu ul.links li.first a:hover,
#primary-menu ul.links li.first a:focus,
#primary-menu ul.links li.first a:active {
color:#97292B
}


#header-bottom {
left:35px;
position:absolute;
top:92px;
}

ul.primary-links {
font-family:sans-serif,"Lucida Grande",Verdana,Arial;
list-style-image:none;
list-style-position:outside;
list-style-type:none;
margin:0;
padding:0;
}

ul.primary-links li {
float:left;
margin:0 1px;
}

ul.primary-links li a {
display:inline-block;
height:40px;
width:300px;
}

li#Community a,
li#Marketplace a,
li#Info_Center a {
width: 291px;
height: 40px;
color: transparent;
display: inline-block;
}

li#Community a {
background:transparent url(images/icons/community.png) no-repeat scroll left top;
}
li#Marketplace a{
background:transparent url(images/icons/community.png) no-repeat scroll left top;
}
li#Info_Center a{
background:transparent url(images/icons/community.png) no-repeat scroll left top;
}

li#Community a:hover,
li#Marketplace a:hover,
li#Info_Center a:hover{
background-position: 0 -40px;
}

li#Community a.active,
li#Marketplace a.active,
li#Info_Center a.active{
background-position: 0 -80px;
}

Here's the PHP I added to the Template.tpl.php to make the turn the primary links into images.

// Use icons for primary menu
function primary_links_icons_only() {
  $links = menu_primary_links();
  $level_tmp = explode('-', key($links));
  $level = $level_tmp[0];
/*   $output = "<ul class=\"links-$level\">\n"; */
  $output = "<ul class=\"primary-links\">\n";
  $l2i['pattern'] = '$(<a.*>)(.*)(</a>)$ie';
  $l2i['replacement'] = "\"\\1\".'<img src=\"/'. path_to_theme() .'/images/icons/'.str_replace(' ','_',strtolower('\\2')).'.png\" alt=\"\\2\" />\\3'";
  if ($links) {
    foreach ($links as $link) {
			$link = l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']);
			$cssid = str_replace(' ', '_', strip_tags($link));
			$output .= '<li id="'.$cssid.'">'. preg_replace($l2i['pattern'],$l2i['replacement'],$link) .'</li>';
    };

  $output .= '</ul>';
  }
  return $output;
}

Here's the code I added to the page.tpl.php to print the above function:

  <?php if ($primary_links): ?>
      <div class="clearfix"></div>
      <div id="header-bottom">
   		 <?php print primary_links_icons_only(); ?>  
   		</div><!-- /header-bottom -->
      <?php endif; ?> 
      <div class="clearfix"></div>
     </div>
    </div> 

    <div id="navigation">
    
      <?php if ($navigation_right || $search_box): ?>
      <div id="navigation-right">
        <?php if ($search_box): ?>
        <div id="search-box">
          <?php print $search_box; ?>
        </div><!-- /search-box -->
        <?php endif; ?>
        <?php print $navigation_right; ?>
      </div><!-- /navigation-right -->
      <?php endif; ?>
      <?php if ($secondary_links): ?>
     		<div id="primary-menu">
      		<?php {print theme('links', $secondary_links);} ?>
      		</div>
      		<?php else: ?>
      		<div id="mission">
      		<?php print $mission; ?>
      		</div>
      	<?php endif?>
	   <!-- /primary_menu -->

I've updated the CSS on the live site... so if you log in to the live site (www.mycommunity.org) with the DrupalTest user. you should see the changes. I did not load the changes to the Dev site.

marcvangend’s picture

Maybe it's me, but it still doesn't look right here, using FF 3.0.9, Opera 9.64 and IE7.
When validating, I see a lot more than just "a few comments syntax": http://validator.w3.org/check?uri=http%3A%2F%2Fwww.myforeskin.org. I still think it might be part of the problem.

foodin65’s picture

Thanks for that cool validator site link. I'm really new to this whole "lets write custome code" thing. So all of those errors had something do to with a custom php block that I had written. I've fixed all of those errors with the exception of the unnamed fph2 css class. It's telling me that it's unnamed. I don't know how to name it. It's a special css class I added to my local.css file to get a specific color on a second word in a title.

So after fixing all of those errors, the custom tabs still don't show properly. Still need help. Thanks.

Jeff Burnz’s picture

Dude, the sites have totally different approach to theming the primary links, man, please be more clear about which site is which and what you want :/

/***********************/
/* Primary Links Images*/
/***********************/

#header-bottom {
  left:35px;
  position:  absolute;
  top: 90px;
}

ul.primary-links {
  list-style: none;
  margin: 0;
  padding: 0;
}

ul.primary-links li {
  float: left;
  margin: 0 10px 0 0;
}

ul.primary-links li a {
  display: block;
  margin: 10px 0 0 0;
}

li#Community a {
  width: 300px;
  height: 40px;
  margin: 0;
  overflow: hidden;
}

li#Community img {
  position: relative;
  top: 0;  
}

li#Community a.active img {
  top: -80px;
}

li#Community a:hover img {
  top: -80px;
}

This works (in Firefox3 at least), here's a screenshot http://i40.tinypic.com/v4uxxz.png

Later.

foodin65’s picture

This worked!

I've updated the theme on the site now and I can actually use the Tabs. This is awesome. Thanks a ton!

I've got three very small issues now though.
Solved! -- 1) For whatever reason the Info Center tab is not doing the hover or active class... the code looks right to me... but i could be missing something.

2) when you navigate to a page that doesn't have Primary Links Children (http://www.myforeskin.org/content/marketplace - for instance), then the white bar that the mission statement is in moves up one pixel and makes the tabs look off... any ideas?

3) I don't know how to keep the tab in it's active state when one of it's children is selected. I've tried the Active trail classes.. but they don't seem to apply to my custom tabs. What I want to have happen is this: When I click on the Community Tab, it changes to background position -80px. That's good, but when I click on one of the links under the Community tab, such as "Portal"... the background position of the community tab reverts to -0px. I would like it to stay at -80px so long as I'm on one of the children of the Community tab. Ditto for Marketplace and InfoCenter Tabs.

Again... thank you! You have helped me a ton.
Richard

marcvangend’s picture

The problem with 'fph2' is that you can't just go and invent a new html tag. If you put <fph2> in your html code, it is not a css class, it's an invalid tag. A class name would look like this:

<div class="fph2">What's all the <span>buzz</span> about?</div>

And in your css you can address it like this:

div.fph2 {
  font-size: 2em;
}

But wait! Assuming that "fph2" means "front page h2", there's an even better method. Let's use this html:

<h2>What's all the <span>buzz</span> about?</h2>

No classnames, you may ask? Well, not here. But your theme already adds the 'front' class to the body tag of the front page, so you can now use:

.front h2 {
  font-size: 2em;
}

By using a h2 tag instead of a div, you will improve the semantics of your code and the search results, both in Drupal and on search engines like Google.

foodin65’s picture

I've not made these changes yet... but I will soon and i'll get back to you. Thanks for the information. I'm learning a ton just by asking questions. You guys are really great.

Richard