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 {......}


All times are GMT -6. The time now is 08:00 AM.

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