Slide 1

Slide 1 text

Zazzy WordPress Navigation Presented by: Rachel Baker @rachelbaker www.rachelbaker.me Freelance Web Developer Plugged In Consulting www.pluggedinconsulting.com Courtesy of: CSS Tricks & jQuery Magic

Slide 2

Slide 2 text

There is no such thing as Navigation Gnomes Rachel Baker - WordCamp Milwaukee 2012 PHASE 1 PHASE 2 PHASE 3 Build Website ? Happy Visitors

Slide 3

Slide 3 text

Rachel Baker - WordCamp Milwaukee 2012 Who is Your Audience? What are they Expecting? http://xkcd.com/773/

Slide 4

Slide 4 text

Appearance -> Menus FTW Rachel Baker - WordCamp Milwaukee 2012

Slide 5

Slide 5 text

Rachel Baker - WordCamp Milwaukee 2012 Get Fancy. Expand Your Options.

Slide 6

Slide 6 text

Rachel Baker - WordCamp Milwaukee 2012 Rachel Baker Relationships Meta Data http://gmpg.org/xfn/creator

Slide 7

Slide 7 text

Rachel Baker - WordCamp Milwaukee 2012 Add Relationships to Menu Items Heather Acton

Slide 8

Slide 8 text

Rachel Baker - WordCamp Milwaukee 2012 Boring Navigation Menu

Slide 9

Slide 9 text

Rachel Baker - WordCamp Milwaukee 2012 Not-so-scary Custom Menu Code

Slide 10

Slide 10 text

Rachel Baker - WordCamp Milwaukee 2012 #menu-top-navigation-bar .current-menu-item > a, #menu-top-navigation-bar .current-menu-ancestor > a, #menu-top-navigation-bar .current_page_item > a, #menu-top-navigation-bar .current_page_ancestor > a { background-color: #d9d9d9; color: #2a3238; } Show Visitors Where They Are

Slide 11

Slide 11 text

Rachel Baker - WordCamp Milwaukee 2012 #menu-top-navigation-bar li:hover > a, #menu-top-navigation-bar a:focus { background: #7ab43b; color: #FFF; } #menu-top-navigation-bar .sub-menu li:hover > a, #menu-top-navigation-bar .sub-menu ul li:hover > a, #menu-top-navigation-bar .sub-menu a:focus { background: #7ab43b; color: #FFF; } Make Hovering Helpful

Slide 12

Slide 12 text

Icons = Visual Cues & Icons = Confused Visitors Rachel Baker - WordCamp Milwaukee 2012 Beware!! W43218 790-= P%*(#

Slide 13

Slide 13 text

Rachel Baker - WordCamp Milwaukee 2012 Zurb Foundation Icons http://www.zurb.com/playground/foundation-icons @font-face { font-family: 'FoundationFont[Name]'; src: url('fonts/foundation-icons-[name].eot'); src: url('fonts/foundation-icons-[name].eot?#iefix') format('embedded-opentype'), url('fonts/foundation-icons-[name].woff') format('woff'), url('fonts/foundation-icons-[name].ttf') format('truetype'), url('fonts/foundation-icons-[name].svg#FoundationIcons[Name]') format('svg'); font-weight: normal; font-style: normal; } .glyph { cursor: default; font-size: 16px; line-height: 1; } .glyph.general { font-family: 'FoundationIcons[Name]'; } a

Slide 14

Slide 14 text

Rachel Baker - WordCamp Milwaukee 2012 Add Icons Directly to Navigation Labels h Contact

Slide 15

Slide 15 text

Menu Item Descriptions Rachel Baker - WordCamp Milwaukee 2012 Give context and add more detail

Slide 16

Slide 16 text

Rachel Baker - WordCamp Milwaukee 2012 // Custom Walker that adds description support class Description_walker extends Walker_Nav_Menu { function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $class_names = ' class="'. esc_attr( $class_names ) . '"'; $output .= $indent . '
  • '; $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; $prepend = ''; $append = ''; $description = ! empty( $item->description ) ? ''.esc_attr( $item->description ).'' : ''; if($depth != 0) { $description = $append = $prepend = ""; } $item_output = $args->before; $item_output .= ''; $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append; $item_output .= $description.$args->link_after; $item_output .= ''; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } Slightly Scary Custom Walker
  • Slide 17

    Slide 17 text

    Rachel Baker - WordCamp Milwaukee 2012 When One or Two Words Are Not Enough .description { line-height: 1; font-size: 10px; margin: -10px 0 5px 0; display: block; } 'primary', 'walker' => new description_walker ) ); ?>

    Slide 18

    Slide 18 text

    Custom Classes Rachel Baker - WordCamp Milwaukee 2012 Add individual style to menu items

    Slide 19

    Slide 19 text

    Rachel Baker - WordCamp Milwaukee 2012 Highlight Important Menu Items #menu-top-navigation-bar .right { float: right; background-color: #528400; }

    Slide 20

    Slide 20 text

    Go Further with jQuery Manipulation Rachel Baker - WordCamp Milwaukee 2012 Add individual style to menu items (function($) { $.fn.splitSubmenus = function(newSubmenuClass) { // declaring default classes for the two submenu columns var leftSubmenuClass = "left "; var rightSubmenuClass = "right "; //assign newSubmenuClass to be the passed in string or use "sub-menu" as the default var newSubmenuClass = newSubmenuClass || "sub-menu", Submenu = this, //create two new Submenus, with default classes added to any declared class leftNewSubmenu = $("
      ", {"class": leftSubmenuClass +newSubmenuClass}), rightNewSubmenu = $("
        ", {"class": rightSubmenuClass +newSubmenuClass}), SubmenuItems = Submenu.children("li"), //get the items that we need to split up SubmenuLength = SubmenuItems.size(), //get the number of items to split splitPoint = Math.ceil(SubmenuLength/2); //the split point is total/2 rounded up. //loop through each item in the Submenu SubmenuItems.each(function(i, item) { //if i < splitPoint, add the item to the first of the two new Submenus we created called leftNewSubmenu //else, add the item to the second of the new Submenus, called rightNewSubmenu //jQuery's append() method puts the item in as the last child of the element we invoke it on (i < splitPoint) ? leftNewSubmenu.append(item) : rightNewSubmenu.append(item); }); //add the two new Submenus and then remove the old one Submenu.after(leftNewSubmenu).after(rightNewSubmenu).remove(); } })(jQuery);

        Slide 21

        Slide 21 text

        Rachel Baker - WordCamp Milwaukee 2012 Split Long Submenus into Columns #menu-top-navigation-bar .right.sub-menu { float: right; margin: 0; position: absolute; top: 3.433em; left: 188px; width: 188px; z-index: 99999; } #menu-top-navigation-bar .left.sub-menu{ float: left; margin: 0; position: absolute; top: 3.433em; left: 0; width: 188px; z-index: 99999; } jQuery(document).ready(function(){ jQuery("#menu-item-31 .sub-menu").splitSubmenus(); });

        Slide 22

        Slide 22 text

        Don’t Stop Believin’ Rachel Baker - WordCamp Milwaukee 2012 Download the Demo Child Theme: http://www.smashingmagazine.com/2011/06/06/planning-and-implementing- website-navigation/ http://psychobserver.com/usability/usability-sense-navigation-hierarchy/ https://github.com/rachelbaker/milwaukee2012 Navigation Usability: Font Icons: http://www.zurb.com/playground/foundation-icons http://somerandomdude.com/work/iconic/ http://icons.marekventur.de/