Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Page & Category Menu Bars (http://forum.bytesforall.com/forumdisplay.php?f=10)
-   -   [SOLVED] Is it possible to keep the PARENT page highlighted in the menu? (http://forum.bytesforall.com/showthread.php?t=4720)

qda Dec 4, 2009 01:58 PM

[SOLVED] Is it possible to keep the PARENT page highlighted in the menu?
 
Is there a way to make the parent page in the Page Menu highlighted when one of it's child pages is visited?

juggledad Dec 5, 2009 05:34 AM

you can use a CSS Insert (ATO->add HTML/CSS Inserts->CSS Inserts) like this
HTML Code:

/* ================================================ */
/* Here is how to change the child menu items      */
/* ================================================ */
li.current_page_item ul.rMenu-ver li a:link,
li.current_page_item ul.rMenu-ver li a:active,
li.current_page_item ul.rMenu-ver li a:visited,
li.current_page_item ul.rMenu-ver li a:hover,
li.current_page_item ul.rMenu-ver li,
li.current_page_item ul.rMenu-ver {
        background: #ffffff !important;
        color: #2912E7 !important;
}


qda Dec 6, 2009 01:45 PM

Quote:

Originally Posted by juggledad (Post 20188)
you can use a CSS Insert (ATO->add HTML/CSS Inserts->CSS Inserts) like this
HTML Code:

/* ================================================ */
/* Here is how to change the child menu items      */
/* ================================================ */
li.current_page_item ul.rMenu-ver li a:link,
li.current_page_item ul.rMenu-ver li a:active,
li.current_page_item ul.rMenu-ver li a:visited,
li.current_page_item ul.rMenu-ver li a:hover,
li.current_page_item ul.rMenu-ver li,
li.current_page_item ul.rMenu-ver {
        background: #ffffff !important;
        color: #2912E7 !important;
}


The comment in the code above says 'to change the child menu items' - before I try it, I want to confirm that we are talking about changing the PARENT <li> in the page menu, when a child page is visited.

juggledad Dec 6, 2009 08:24 PM

sorry, copied the wrong code try this
HTML Code:

/* ================================================ */
/* how to highlight parent of current page          */
/* ================================================ */
ul.rMenu li.current_page_parent a:link,
ul.rMenu li.current_page_parent a:active,
ul.rMenu li.current_page_parent a:hover,
ul.rMenu li.current_page_parent a:visited,
ul.rMenu li.current_page_parent {
background: #00ffff !important;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */

Note if you have A the parent of B the parent of C and you are on page C, this will only highlight B, if you want A and B highlighted use current_page_ancestor instead of current_page_parent

vonspark Jan 29, 2010 07:24 AM

This fixed my problem! Thanks a lot!

interfasys Aug 7, 2010 11:10 AM

Quote:

Originally Posted by juggledad (Post 20307)
Note if you have A the parent of B the parent of C and you are on page C, this will only highlight B, if you want A and B highlighted use current_page_ancestor instead of current_page_parent

I've tried with current_page_ancestor, but it doesn't really work, because it highlights all the B items, so the user doesn't know where he is in the B sub-menu.
The selected elements of A and B have the current-menu-ancestor class, but sub-elements inherit the properties.

juggledad Aug 7, 2010 11:55 AM

In WP 3.0+ with the new menus, try using 'current-menu-parent' in place of 'current_page_parent'

marced Dec 5, 2010 05:59 AM

Hi Juggledad, I used the code and it's working, so it highlights the parent when child is active. But as said by Interfasys, it highlights all the sub-items then too, so a visitor doesn't know in which child he is.

I replaced 'current_page_parent' by 'current-menu-parent' but that doesn't highlight the parent anymore. Already a solution for that?

juggledad Dec 5, 2010 09:29 AM

CSS is cascading style sheets so a change to an element effects it's children. To prevent this you have to add more CSS for the children to reset the change

rlenz Dec 9, 2010 07:17 AM

thanks for that information!


robert

marced Dec 11, 2010 04:45 AM

Thanks JD!

mindblower Jan 26, 2011 03:33 PM

hi

i can't get current_page_parent to work on my site...

header:

<ul id="pagemenu">
<li <?php if (is_home()) { ?> class="current_page_item" <?php } ?>><a href="<?php echo get_option('home'); ?>/">Home</a></li>
<?php wp_list_pages('depth=1&sort_column=menu_order&titl e_li=' ); ?>
</ul>

sidebar:

<ul>

<?php wp_list_pages('include=19,21,23,25&title_li=') ; ?>

</ul>


Can someone help ??

Thanks a lot!

juggledad Jan 26, 2011 04:23 PM

What version of atahualpa are you using?
What is the URL?

cafemag Mar 18, 2011 02:24 PM

I just want to say that this code works great:
Code:

/* ================================================ */
/* how to highlight parent of current page          */
/* ================================================ */
ul.rMenu li.current_page_parent a:link,
ul.rMenu li.current_page_parent a:active,
ul.rMenu li.current_page_parent a:hover,
ul.rMenu li.current_page_parent a:visited,
ul.rMenu li.current_page_parent {
background: #00ffff !important;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */

I placed it above the "clearfix hacks section" in the css.php file.. I am also using the horizontal menu children mod w/ the PHP Code widget that makes it possible to lay out a sub menu in a dropline format of excluded pages and it still highlights the parent page when those children are selected.. so thats awesome and now I want to figure out how to keep the children page selected when not hovering over it and on that page as well..

cafemag Mar 18, 2011 02:40 PM

so i actually dont want to use a background color as the selection mode.. is there anyway to have it change the color of the text instead? i am only using a color change on the text its self in my menus and keeping the background color the same as the body background color..

cafemag Mar 18, 2011 02:42 PM

sorry to bug n/m figured it out..
Code:

/* ================================================ */
/* how to highlight parent of current page          */
/* ================================================ */
ul.rMenu li.current_page_parent a:link,
ul.rMenu li.current_page_parent a:active,
ul.rMenu li.current_page_parent a:hover,
ul.rMenu li.current_page_parent a:visited,
ul.rMenu li.current_page_parent {
color: #00AFFE !important;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */

this will just keep the font hover.. cool!

cafemag Mar 18, 2011 03:19 PM

ok and just for fluidity I figured out how to make the PHP CODE widget change the color of the selected submenu page on my menu by adding simple font color code to each page that it is currently on

Code:

<?php

echo "<div id=\"menu2\">";
echo "<ul class=\"clearfix rMenu-hor rMenu\" id=\"rmenu\">";

$curr_page_id = get_query_var('page_id');

switch ($curr_page_id) {
    case 2:
        echo "
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=11\">CATEGORY 01</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=43\">CATEGORY 02</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=45\">CATEGORY 03</a></li>
        ";
        break;

    case 11:
        echo "
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=11\"><font color=\"#00AFFE\">CATEGORY 01</font></a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=43\">CATEGORY 02</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=45\">CATEGORY 03</a></li>
        ";
        break;

    case 43:
        echo "
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=11\">CATEGORY 01</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=43\"><font color=\"#00AFFE\">CATEGORY 02</font></a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=45\">CATEGORY 03</a></li>
        ";
        break;

    case 45:
        echo "
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=11\">CATEGORY 01</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=43\">CATEGORY 02</a></li>
<li class=\"cat-item cat-item-1\"><a href=\"http://www.y-studios.com/wordpress/?page_id=45\"><font color=\"#00AFFE\">CATEGORY 03</font></a></li>
        ";
        break;

    default:
      echo "&nbsp; ";
}
echo "</ul></div>";
?>

not the most efficient way to get a horizontal dropline menu but this works for my client..

striped aardvark Jul 22, 2011 10:01 AM

i can't seem to get this working.

http://greeningmarketing.ca/2011/case-studies/ribfest/ is the child page.. i'd like the parent to be highlighted when the child is active, but don't want to use a dropdown menu. i used the code suggested above, but it doesn't seem to work for me, whether i have the dropdown in place or not.

WP 3.1.4
ATA 3.6.7

thank-you!

juggledad Jul 22, 2011 03:31 PM

I'd suggest you use FireBug in FireFox to examine the menu items to see what classes are being used. It also depends on if you are using the Atahualpa menu or the WordPress menu
do you have the 367 patches applied? (New Versions & Updates forum)

bswb97 Feb 21, 2012 08:39 PM

I'm bringing this thread back from the dead. See here (scroll down to the Admin Login link and click it to bypass the construction splash screen)

http://www.ddubcustomsportswear.com/?page_id=22

I have inserted the parent code:

HTML Code:

/* ================================================ */
/* how to highlight parent of current page          */
/* ================================================ */
ul.rMenu li.current-menu-parent a:link,
ul.rMenu li.current-menu-parent a:active,
ul.rMenu li.current-menu-parent a:hover,
ul.rMenu li.current-menu-parent a:visited,
ul.rMenu li.current-menu-parent {
color: #fff !important;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */

I'm using Chrome's Element Inspect to view the CSS for the child menu items. I am able to manipulate other child elements (non-current) with ul.rMenu-ver but I can't seem to locate one specifically for the current item's child. When I inspect child elements, I see the items above.

I'm not too experienced with Clearfix, but would that do the trick? And if so, what's the proper way to implement it?

juggledad Feb 22, 2012 05:01 AM

looks fine in Safari and FireFox on the mac, if I select 'Long sleeve Jerseys' then 'Products' is white

bswb97 Feb 22, 2012 08:11 AM

I should have been clearer -- I want the Parent to stay highlighted BUT the current sub-menu to use the default styling.

For example, the default styling for sub-menus is that links are blue, hover is red (see what happens when you mouse over Services).

Thus, when you are on Products > Accessories, Products stays highlighted in white but the sub-menu below it uses the default sub-menu styling -- links are blue, hover is red. Does that make sense?

When I inspect elements, everything is related to ul.rMenu -- I don't see specific items for the child of the current menu item. That's the hurdle I keep tripping on.

juggledad Feb 22, 2012 08:35 AM

CSS is CASCADING - so if you want the sub menu items to be the same as the default, you must code more css to revert them to the original styling.

btw, a black background and dark blue menu items is very hard to read

bswb97 Feb 22, 2012 09:03 AM

Yeah, I'm not keen on the dark blue but it's what the client wants. The customer is always right, right? ;)

I'm using Inspect Element to try and figure out WHAT I need to add to restore the default styling. I know what I want to use for link and hover, but I can't pinpoint the element itself when I look at the style sheet. It seems like the only elements listed are for the parent.

juggledad Feb 22, 2012 03:58 PM

you need to use something like
HTML Code:

ul.rMenu li.current-menu-parent ul li {......}

bswb97 Feb 23, 2012 08:55 AM

It's close, and thanks JD for the inclusion of the UL, I was stuck looking at the class. Here's my code:

HTML Code:

ul.rMenu li.current-menu-parent ul li a:link
{color: #204572 !important;}
ul.rMenu li.current-menu-parent ul li a:active
{color: #fff !important;}
ul.rMenu li.current-menu-parent ul li a:hover
{color: #DC2509 !important;}
ul.rMenu li.current-menu-parent ul li a:visited
{color: #204572 !important;}

It's halfway there. You can look at http://www.ddubcustomsportswear.com/?page_id=25 (remember the splash page bypass at the bottom) and see that the red hover is working EXCEPT on the first three items. The main links are now blue, which is good, but the active is not turning white.

So it should be:

Link & visited: Blue
Active: White
Hover: Red

Am I just not seeing a typo here?

juggledad Feb 23, 2012 10:04 AM

FireBug shows me you need
HTML Code:

div#menu1 ul.rMenu li.current-menu-item a:link, div#menu1 ul.rMenu li.current-menu-item a:active, div#menu1 ul.rMenu li.current-menu-item a:hover, div#menu1 ul.rMenu li.current-menu-item a:visited, div#menu1 ul.rMenu li.current_page_item a:link, div#menu1 ul.rMenu li.current_page_item a:active, div#menu1 ul.rMenu li.current_page_item a:hover, div#menu1 ul.rMenu li.current_page_item a:visited, div#menu1 ul.rMenu li a:hover {
    color: red;
}


bswb97 Feb 23, 2012 05:31 PM

This continues to frustrate me. I've got it now where it has:

CORRECT:
Parent item (white on current)
Inactive child links (blue)
Hover child links (red)

INCORRECT:
Active child page -- blue, should be white

I went to Firebug instead of Chrome Element. They're formatted a little differently, so they could be displaying the same info. In any case, I searched for the blue code #204572. This is what I see:

HTML Code:

ul.rMenu li.current-menu-parent ul li a:active {
    color: #FFFFFF !important;
}

ul.rMenu li.current-menu-parent ul li a:link, ul.rMenu li.current-menu-parent ul li a:visited {
    color: #204572 !important;
}

I think the Blue for link/visited is overriding the white for active. When I put them at equal importance, it shows that the blue wins out. If I swap the order of them, it shows up as whichever comes latest. If I remove the important from either one, the one marked important shows up on all elements except hover.

Makes sense to me from the way CSS is structured, but is there a way to get the Active Child page to show up as a different color from the links/visited links/hover?

bswb97 Feb 27, 2012 09:01 AM

Anyone? Or should I wave the white flag on this?

lmilesw Feb 27, 2012 09:18 AM

The brute force way would be to add the following in CSS Inserts.
HTML Code:

div#menu1 ul.rMenu li.current-menu-item a:link, div#menu1 ul.rMenu li.current-menu-item a:active, div#menu1 ul.rMenu li.current-menu-item a:hover, div#menu1 ul.rMenu li.current-menu-item a:visited, div#menu1 ul.rMenu li.current_page_item a:link, div#menu1 ul.rMenu li.current_page_item a:active, div#menu1 ul.rMenu li.current_page_item a:hover, div#menu1 ul.rMenu li.current_page_item a:visited, div#menu1 ul.rMenu li a:hover {
    color: #fff !important;
}

Also I can barely read your menu items on my laptop... Not great for usability.

bswb97 Feb 27, 2012 11:42 AM

Close but no cigar. This creates a white hover state instead of the red. I tried removing the hover elements and that just created the scenario I previously described.

I think I'm giving up on this one. Any recommendations on a CSS-friendly menu plugin?

Re: color scheme...it's what the site owner wanted. I originally designed it as a light gray but he wanted the blue to go with the logo. Sometimes you can explain and explain but they're hell-bent on their decisions! ;)

lmilesw Feb 27, 2012 12:11 PM

Did you try taking out the hover code? You may have to play with this code a bit.

bswb97 Feb 27, 2012 12:21 PM

Yeah, I tried removing the hover elements. Tried also overriding them with different placement in the inserts, and a few other variations but it ultimately reproduced the same effects that I got before.

I'll try going the other route with a plugin, so recommendations are welcome.

lmilesw Feb 27, 2012 12:23 PM

This worked for me
HTML Code:

div#menu1 ul.rMenu li.current-menu-item a:link, div#menu1 ul.rMenu li.current-menu-item a:active, div#menu1 ul.rMenu li.current-menu-item a:visited, div#menu1 ul.rMenu li.current_page_item a:link, div#menu1 ul.rMenu li.current_page_item a:active, div#menu1 ul.rMenu li.current_page_item a:visited {
color: #ffffff !important;
}


bswb97 Feb 27, 2012 12:55 PM

I tried it I think the issue here stems from the use of the Parent code (earlier in the thread):

HTML Code:

/* ================================================ */
/* how to highlight parent of current page          */
/* ================================================ */
ul.rMenu li.current-menu-parent a:link,
ul.rMenu li.current-menu-parent a:active,
ul.rMenu li.current-menu-parent a:hover,
ul.rMenu li.current-menu-parent a:visited,
ul.rMenu li.current-menu-parent {
color: #fff !important;
}

/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */

If I put in your code WITH this code, then the result turns everything white. I think it supersedes the CSS defaults (blue links, red hover). That's what I have saved right now, you can check it out.

If, however, I remove the parent code, then everything fits into place EXCEPT the parent item. For example, the active child is white, the other child links are blue, the hover links are red. It's essentially the CSS default.

My original configuration had the Parent code (above) and the following three items that I have currently removed:

1) Blue colors on links:
ul.rMenu li.current-menu-parent ul li a:link, ul.rMenu li.current-menu-parent ul li a:visited
{color: #204572 !important;}

2) White on active link (NOT WORKING)
ul.rMenu li.current-menu-parent ul li a:active
{color: #fff;}

3) Red on hover:
ul.rMenu li.current-menu-parent ul li a:hover
{color: #DC2509 !important;}

The final variation I tried was the Parent code + your code except I altered the parent code to get rid of the link, hover, and visited states. This failed to activate the Parent as white.

lmilesw Feb 27, 2012 01:33 PM

So maybe instead of the code I just gave you perhaps the following.
HTML Code:

div#menu1 ul.rMenu li.current_page_item a {
color: #fff !important;
}

This is where I play with Firebug to determine what works. There is somtimes so much CSS interaction it is next to impossible to give you the exact code.

bswb97 Feb 27, 2012 02:48 PM

THAT DID IT!!!

Or, more specifically, this combination of code:

1) Parent menu code:
HTML Code:

ul.rMenu li.current-menu-parent a:link,
ul.rMenu li.current-menu-parent a:active,
ul.rMenu li.current-menu-parent a:hover,
ul.rMenu li.current-menu-parent a:visited,
ul.rMenu li.current-menu-parent {
color: #fff !important;
}

2) Child menu code:
HTML Code:

ul.rMenu li.current-menu-parent ul li a:link, ul.rMenu li.current-menu-parent ul li a:visited
{color: #204572 !important;}
ul.rMenu li.current-menu-parent ul li a:active
{color: #fff;}
ul.rMenu li.current-menu-parent ul li a:hover
{color: #DC2509 !important;}

3) Active child menu code:
HTML Code:

div#menu1 ul.rMenu li.current_page_item a {
color: #fff !important;
}

You've earned my donation for the day!

Harald Mar 16, 2012 08:55 PM

I used the code above to highlight the parent menu when on a child page, and it worked except when I try to make the background gradient. The text still changes but not the background. This is the CSS i used in the CSS Insert section.
HTML Code:

/* how to highlight parent of current page * * * * **/
/* ================================================ */
div#menu1 ul.rMenu li.current_page_parent a:visited {
background: -webkit-gradient(linear, left top, left bottom, from(#6D86BC), to(#D5DDEC)) !important;
background: -moz-linear-gradient(top,  #6D86BC,  #D5DDEC) !important;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#6D86BC', endColorstr='#D5DDEC') !important;
color: #ffffff !important;
}
/* ++++++++++++++++++++++++++++++++++++++++++++++++++ */
/* Adjustments for the menu bars, which in their default
state have 1px borders plus -1px margins to avoid 1+1=2px
borders between neighbor items. */
ul.rMenu-hor ul, ul.rMenu-hRight ul { margin-top: 0px; background: transparent;}
ul.rMenu-hor li { margin-bottom: 0px; margin-top: 0px; margin-left: 0px; background: transparent; }
ul.rMenu-hor { padding-left: 0px; background: transparent; }
ul.rMenu-ver li { margin-top: 0xp; background: transparent; }

div#menu1 ul.rMenu li a, div#menu2 ul.rMenu li a {
padding: 9px 11px 6px 11px;
background:-webkit-gradient(linear, left top, left bottom, from(#D5DDEC), to(#ffffff));
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#D5DDEC', endColorstr='#ffffff');
background: -moz-linear-gradient(top,  #D5DDEC,  #ffffff);
-webkit-box-shadow: rgba(0,0,0,0.55) 0px 1px 1px; -moz-box-shadow: rgba(0,0,0,0.35) 0px 1px 1px;
-moz-border-radius: 3px; -khtml-border-radius: 3px; -webkit-border-radius: 3px; border-radius: 3px;
}

I use the latest Wordpress and Atahualpa.
Any suggestions?

lmilesw Mar 17, 2012 05:55 AM

I would double check your gradient CSS. That can be a bit finicky. For instance I have never seen from and to in CSS. Where did you get this code?

Harald Mar 17, 2012 07:13 AM

Thanks for your quick response. I found it on this site http://webdesignerwall.com/tutorials...r-css-gradient. The strange thing is that the code works in default stage but not in current stage.


All times are GMT -6. The time now is 07:31 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.