Good day

Thanks for themes

How override h2 in
<h2 class="block-title element-invisible">Main menu</h2>

I founded this

 if (isset($vars['main_menu'])) {

    $text = block_get_blocks_by_region('menu_bar') ? t('Navigation') : t('Main menu');

    $vars['primary_navigation'] = theme('links', array(
      'links' => $vars['main_menu'],
      'attributes' => array(
        'class' => array('menu', 'primary-menu', 'clearfix'),
       ),
      'heading' => array(
        'text' => $text,
        'level' => 'h2',
        'class' => array('element-invisible'),
      )
    ));
  }

but my overide without effect (I try change "level")

Comments

Valeratal’s picture

block--menu-bar.tpl.php

Jeff Burnz’s picture

Why do you want to change the heading level?

Valeratal’s picture

SEO, Semantic, logic

I think "Menu", "Pager", not main parts of my site, my content.

block--menu-bar.tpl.php - override if use superfish menu

default primary menu not overided

Jeff Burnz’s picture

These headings are included for two reasons:

Semantic structure (remember, this is HTML5, not XHTML), and accessibility (so screen reader users can more easily navigate by headings and so they have appropriate list headings to contextualize what they are hearing).

By removing these headings you do two things:

1) break the semantic outline of the document.

2) reduce the accessibility of the document.

Of course if you want poor semantics thats entirely up to you, but it sounds to me like you are using old school logic and applying it to new technology - HTML5 requires a different mindset.

Valeratal’s picture

1. Where I can read about inserting h2 in html5 ?

I read http://www.w3schools.com/html5/default.asp , but not found nothing about "h2"

http://www.whatwg.org/specs/web-apps/current-work/#headings-and-sections - nothing any using h2 in menu, breadcumbs, paging, etc

2. Screen reader users - very small group. (IE 6 users - more)

Jeff Burnz’s picture

What you want to learn about is the "outline", which shows the document structure. When a machine reads a document it trys to figure out whats important on the page (whatever it considers to be important, depends on the machine and its purpose), it can use the document structure to find this out, in other words the machine parses the page and looks at sectioning and implied sectioning elements. Critics have often applauded this theme for its superior outline (its not perfect, but its pretty dam near as good as it gets in Drupal 7).

Your thinking is rooted in HTML4, where you are simply looking at one heading and applying/assuming it carries some level of "importance", this idea is vastly improved (and rather more complicated) in HTML5. The entire document structure is far far more important than one single heading. Remember - this is much more than headings and heading levels, you need to look at the sectioning elements as well (and each elements relative nesting level).

In essence what the machine can do (with a proper outline) is figure out exactly where each section is, how it fits into the overall document tree, and what is important on the page.

As for accessibility - its a requirement in accessibility for all lists to have headings (this makes a lot of sense, and fits very well with HTML5). As for accessibility users mostly using IE6 - no idea where you get that crazy idea from! They use all sorts of browsers just like everyone else, although most tend to use Internet Explorer. Understand that I am one of the main people who worked on accessibility improvements in Drupal 7 core (for nearly 3 years), alongside some of the very smart accessibility folk such as Everett Zufelt and Mike Gifford - and both those guys helped develop this theme, so we have some of the smartest accessibility developers out there who have contributed to this project to build a very accessible and advanced starter theme.

Its also a complete misnomer that accessibility users are a small percentage of users, it can in fact be anywhere from 10 to 20% of all users who have some sort of impediment.

pvasili’s picture

Component: Code » CSS/HTML

2 Jeff Burnz : I don't want use it! Why we can't do disabled it?

Jeff Burnz’s picture

pvasili! You can! Override the function and code! Are you happy now! Good!

Jeff Burnz’s picture

Status: Active » Fixed
Jeff Burnz’s picture

Status: Fixed » Closed (fixed)

Cleaning up.

bohemier’s picture

Hi Jeff - Thanks for the explanation. Accessibility is important...

I believe this should be configurable because in terms of SEO this might not be so good... H2's are important in that area and 'Main Menu' is not what most people want the site to be indexed with. Also, perhaps allow to choose which block element is put there instead of H2?

Thanks !

Jeff Burnz’s picture

I give you a tip, in the latest DEV of Adaptivetheme if you are using the Mobile Menu Toggle extension you can configure the Main and User (secondary) menu headings.

Also if you are really concerned about this and do not want to use the Menu Toggle feature you can always use a block in the Menu Bar region and set any heading you want, or none at all.

bohemier’s picture

Thanks! Configuring the block title allows me to configure what goes inside. I am curious though, I've been searching in the code to find where in AT does this H2 get set? I found this in at_core/inc/preprocess.inc

  // Build a variable for the main menu
  if (isset($vars['main_menu'])) {
    $vars['primary_navigation'] = theme('links', array(
      'links' => $vars['main_menu'],
      'attributes' => array(
        'class' => array('menu', 'primary-menu', 'clearfix'),
       ),
      'heading' => array(
        'text' => t('Main menu'),
        'level' => 'h2',
        'class' => array('element-invisible'),
      )
    ));
  }

Changing the 'level' key to h6 for instance doesn't result in any changes, i.e. I still see an h2 in the rendered html. I also tried clearing all caches.

My theme is an AT (pixture_reloaded) sub theme.

Thanks again Jeff

Jeff Burnz’s picture

Title: How override h2 in h2 class="block-title element-invisible">Main menu</h2 » How to override the heading level for the Main menu

Already answered in this issue.

ProRB’s picture

I ran into this issue as well.

I tried some of the things in this thread, as well as digging through includes, php files, etc.

The solution however, turned out to be VERY simple. Here is how I removed the H2 heading from the Main Menu in my Drupal 7 installation:

  1. Navigate here: domain.extension/admin/structure/block/manage/system/main-menu/configure
  2. Locate the "Block Title" at the top of the page
  3. Input "" in the Block Title
  4. Click "Save Block" at the bottom of the page

Here is a screenshot of what the proper setting looks like: https://i.imgur.com/XvZkECo.png

Here is the code snippet before:

<div class="region region-superfish-menu">
    <div id="block-system-main-menu" class="block block-system block-menu">

  <h2 class="block-title">Main menu</h2>

<div class="content">
  <ul class="menu"><li class="first expanded">

Here is the code snippet after:

 <div class="region region-superfish-menu">
    <div id="block-system-main-menu" class="block block-system block-menu">


<div class="content">
  <ul class="menu"><li class="first expanded">

You will note that the H2 class block-title is completely absent.

Problem Solved!

Does it help with SEO? Who knows, but we did remove it anyway and now our Heading Structure is proper with H1 at the top, all H2-H6 below.