By noraa on
I posted earilier, but perhaps was not clear. I have successfully made my primary links horizontal tabs with images. My css has button_normal.png, button_over.png, and button_current.png. The normal and over are working, but I cannot get the current to show up. I can do it in straight html, but can't get the page.tpl.php file. I cannot seem to get my css code to show up here, so if anyone is willing to help I can email that to them. The id that includes the current button has ids #navcontainer #current and then #navcontainer .currentAncestor
Comments
Post your code
How are you setting the code for #current ?
Drupal assigns a class of .active to the currently selected link. you should try and use this for selecting in css.
I use a slightly different approach to highlighting my current primary link, depending on which section of the site the user is on.
See:
http://drupal.org/node/44704#comment-149460
http://drupal.org/node/44704#comment-151935
Try posting your code again. Are you wrapping it with the code tag when posting?
<code>
</code>
Thanks. It actually worked
Thanks. It actually worked for the first primary link when I changed the .currentAncestor to .active, but two and three are still not showing up. I did wrap the code in the tags last time. I'll try one more time. The original code is below. I've become to understand, with drupal, it's baby steps one by one. I'm excited that that first link works though. Thanks again.
#navcontainer {
margin-right: auto;
margin-left: auto;
width: 680px;
position: relative;
height: 10px;
font-size: 0.8em;
}
#navcontainer #current {
background: no-repeat url(images/button_current.png);
text-shadow: none;
}
#navcontainer .currentAncestor {
background: no-repeat url(images/button_current.png);
text-shadow: none;
}
/* Parent - Level 0 */
#navcontainer ul {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
top: 0;
width: 680px;
left: 0;
}
#navcontainer li {
display: inline;
float: left;
}
#navcontainer a{
width: 113px;
height: 34px;
display: block;
background: no-repeat url(images/button_normal.png);
text-decoration: none;
padding-top: 11px;
color: #3c3c3c;
text-shadow: 0px 1px 0px #ffffff;
text-align: center;
}
#navcontainer a:hover {
background: url(images/button_over.png) no-repeat;
text-shadow: none;
}
#navcontainer a:active {
background: url(images/button_over.png) no-repeat;
text-shadow: none;
}
/* Child - Level 1 */
#navcontainer ul ul {
position: absolute;
left: 0;
top: 32px;
width: inherit;
font-size: 0.99em;
}
#navcontainer ul ul li {
}
#navcontainer ul ul a {
background: none;
padding-top: 1px;
width: 9em;
}
#navcontainer ul ul a:hover{
background: repeat-x url(images/submenu_over.png) center top;
}
#navcontainer ul ul #current{
background: repeat-x url(images/submenu_over.png) center top;
text-shadow: none;
}
#navcontainer ul ul .currentAncestor {
background: repeat-x url(images/submenu_over.png) center top;
text-shadow: none;
}
/* Child - Level 2 */
#navcontainer ul ul ul {
position: absolute;
left: 10px;
top: 20px;
width: inherit;
margin: 0;
white-space: nowrap;
padding: 0px 0px 0px 10px;
}
#navcontainer ul ul ul li {
}
#navcontainer ul ul ul li a {
color: #121212;
text-shadow: none;
}
#navcontainer ul ul ul li a:hover {
text-decoration: none;
background: none;
}
#navcontainer ul ul ul #current {
font-weight: normal;
background: none;
text-shadow: none;
}
#navcontainer ul ul ul ul {
display: none;
}
here's the php
Where is the code outputting
Where is the code outputting html with the id of #current?
try styling the active class instead
Can you also post the html that your page is outputting (just the menu area). I don't want to make any assumptions but you may be applying your css incorectly, or trying to apply css to an ID that doesn't exist.
Also the css suggests that you are using drop down menus? Do you have a test site online that I can look at?
Mark
baby steps still
Oh thank you. You're being so patient. I just added that snippet without changing anything else and NOW I'm getting both first and second links working, but not the third. I don't have this on a live server yet, but think I'll make that my next task. I need to upgrade my 4.7.3 to 4.7.4 I believe. Putting drupal on my live server always gives me anxiety attacks. I fear inviting the entire world into my bedroom (security fears). I'm just so new at this stuff. Here's the html output:
I'll get back with you when I have a live link. Thanks and wish me luck!
Looking at the Nav example
Looking at the Nav example you have posted, I can't see where your #current id is. Clicking on a link should add a class of .active to your link. (Drupal applies this class automatically)
Have a look at this example:
http://www.clubmark.org.uk
This site ouputs the following primary links:
This is achieved with the following code that applies an id to each link.
Clicking on each primary link adds a new class and ID to the body tag. This is achieved by replacing the body tag in page.tpl.php with the following.
The code produces the following style of body tag (for a url starting with of /about/)...
By using the body class as a selector for items within it you can then target each nav item with css.
the last block of css works in the following way...
take css
.section-about #top-nav ul#primary li#primnav2 aworking backwards - style the link (a) within the list item with the ID of primnav2, within the (ul) with the ID of primary, within the div with ID of top-nav.
finally only apply this when the body has a class of ".section-about"
As .section-about will only be applied to the page with a url of /about, the about link (#primnav2) will only appear highlighted within this site section.
Hope this example helps you achieve what you are looking to do. If you do get a live version posted I'll take a look at it.
Mark
Wow, still trying to digest
Wow, still trying to digest this, but I got my site up. It's at www.lifeonilife.com
No content, but it's up. I'm taking this post and studying it now. Thanks for all your help. You're a real gem.
Try clean url's
One more thing...
Try enabling 'clean url's' if you are following the approach above. (under general settings)
This would allow you to use 'gallery' and 'forums' under the path alias. (instead of ?q=node/2)
This would then give you urls of:
http://www.lifeonilife.com/gallery
http://www.lifeonilife.com/forums
you could then apply the css
Nearly there!
Let me start by saying that
Let me start by saying that your help has just amazed me. However, it has prompted a trip to the library for a php book as I just don't understand what's going on enough. I did open the drupal.css file under the misc folder and found some of the primary link ids there. Should I be fiddling with that file or should all this go into the style.css? As you can see, I've not digested all this yet. 1:00am this morning was my brain's limit, and of course, there's all that "normal life" stuff that keeps getting in the way. But you have given enough direction for me to get a grasp on this. Stay tuned, I am confident I'll get this. And then after I get the current button working I want to get that strip of background underneath to change as well. But that's another goal all together. I'm concentrating on the buttons first. Learning is fun when you have a good mentor. Thanks so much again. I used the bluemarine theme to fashion this from, but last nite I noticed that the pushbutton theme seems to have more of the primary link properties that I'm looking for. Anyway, off to the library now.
avoid drupal.css
Best not to customise drupal.css as it could cause problems when updating. If you have something in drupal.css that you need to change, just copy it into style.css as it will overide drupal.css.
Customising an existing theme is probably a good way for you to go. You can always make a backup of the style.css file, delete the contents of style.css and then re-introduce blocks of css saving and previewing the site as you go. This will give you a better understanding of how the theme works.
Also try using Firefox with the web developer extension (if you're not already) It has some really handy features like "view style information" that displays the css rules for specific items on a page, just by clicking on them.
still perplexed but persevering
Hi Markhope,
You do give me hope, but I'm totally stumped by now. I admit that I just do not know enough about this stuff to make sense of it. I am learning a lot as I go though. I have been using Firefox's features. Really good. My page.tpl.php is back to its orignal state. I'll try and recount how I got this far without knowing much. I got my theme idea from Rapidweaver's aqualicious theme. A sample page is at www.memoryflix.info. That's unretouched, uploaded straight from their publishing tool. I then watched dudertown.com's tutorial on custom themes. I copied Drupal's Bluemarine theme for their tutorial and named it aqua. So the style.css and page.tpl.php are originally from Bluemarine. I've tried to keep the naming conventions the same as Rapidweaver's. Eventually, I'd like to have the submenu graphic change colors along with each current tab, i.e., blue with a blue submenu strip, purple with a purple submenu strip. But that is just on the wish list right now. I'm assuming in the end my secondary links can show up in that submenu strip. My current state drupal site is at www.lifeonilife.com. Again, thanks for all your help. I'm sorry to say that your post with all the body changing, etc. just went over my head.
Here's the css from Rapidweaver unretouched:
/* Toolbar Styles */
#navcontainer {
margin-right: auto;
margin-left: auto;
width: 680px;
position: relative;
height: 10px;
font-size: 0.8em;
}
#navcontainer #current {
background: no-repeat url(images/button_current.png);
text-shadow: none;
}
#navcontainer .currentAncestor {
background: no-repeat url(images/button_current.png);
text-shadow: none;
}
/* Parent - Level 0 */
#navcontainer ul {
list-style: none;
margin: 0;
padding: 0;
position: absolute;
top: 0;
width: 680px;
left: 0;
}
#navcontainer li {
display: inline;
float: left;
}
#navcontainer a{
width: 113px;
height: 34px;
display: block;
background: no-repeat url(images/button_normal.png);
text-decoration: none;
padding-top: 11px;
color: #3c3c3c;
text-shadow: 0px 1px 0px #ffffff;
text-align: center;
}
#navcontainer a:hover {
background: url(images/button_over.png) no-repeat;
text-shadow: none;
}
#navcontainer a:active {
}
/* Child - Level 1 */
#navcontainer ul ul {
position: absolute;
left: 0;
top: 32px;
width: inherit;
font-size: 0.99em;
}
#navcontainer ul ul li {
}
#navcontainer ul ul a {
background: none;
padding-top: 1px;
width: 9em;
}
#navcontainer ul ul a:hover{
background: repeat-x url(images/submenu_over.png) center top;
}
#navcontainer ul ul #current{
background: repeat-x url(images/submenu_over.png) center top;
text-shadow: none;
}
#navcontainer ul ul .currentAncestor {
background: repeat-x url(images/submenu_over.png) center top;
text-shadow: none;
}
/* Child - Level 2 */
#navcontainer ul ul ul {
position: absolute;
left: 10px;
top: 20px;
width: inherit;
margin: 0;
white-space: nowrap;
padding: 0px 0px 0px 10px;
}
#navcontainer ul ul ul li {
}
#navcontainer ul ul ul li a {
color: #121212;
text-shadow: none;
}
#navcontainer ul ul ul li a:hover {
text-decoration: none;
background: none;
}
#navcontainer ul ul ul #current {
font-weight: normal;
background: none;
text-shadow: none;
}
#navcontainer ul ul ul ul {
display: none;
}
sorry, here's php
Eureka!!! Finally got
Eureka!!! Finally got everything where it's supposed to be for the current tab to show up properly. Thanks for all your help. Now to get the current tab and submenu strip to change colors. Someday I might even get to the point of adding content to this bad boy!
Glad to see it's working!
Glad you are now getting somewhere, and hope it was worth persevering with.
I think the rapidweaver css was causing some confusion. the #current is an ID and the .currentAncestor is a class meaning you'd need that code in your outputted html. If it isn't in your template then the CSS wont be applied. (but then you probably now know that).
Mark