Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Accessibility errors confusing me


Go to End


9 Posts   4390 Views

Avatar
ianpiper

Community Member, 32 Posts

7 January 2010 at 6:25am

Hi all,

I am trying to get my site to meet WAI Level AA for accessibility. I have one warning and one error from Cynthia Says (http://www.contentquality.com). The error is weird:

"Failure - Document does not contain a META element with the required name: language or language does not have a 'content' value."

Well, it does have such an element. Here it is:

<meta http-equiv="content-language" content="en"/>

This is provided by the $MetaTags variable. My question is, where does this come from? It seems to be from SiteTree.php in sapphire/core/model. But where does the current_lang() method referred here get its language string from. I ask because I want to check whether other values such as "en-GB" would make Cynthia Says notice the language META element. If anyone can suggest why CS might be failing on these apparently spurious grounds I would be grateful.

The second error is more problematic. It is about the search box at the top of my pages. That is provided by the code in Page.php (see end of this posting). Cynthia Says reports that the search form should have a label association:

"Rule: 12.4.1 - Identify all non-hidden INPUT elements that do not have an explicit LABEL association.
Failure - INPUT Element, of Type TEXT, at Line: 69, Column: 75 in FORM Element at Line: 65, Column: 6"

How do I modify the SearchForm() function to provide the form elements with labels that might satisfy Cynthia?

Thanks,

Ian.
--

############# Page.php code ###########
function SearchForm() {
$searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Your search query:';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search')
);

return new SearchForm($this, "SearchForm", $fields, $actions);
}

Avatar
tobych

Community Member, 97 Posts

7 January 2010 at 4:19pm

Edited: 07/01/2010 4:22pm

Ian,

I suggest you break this problem into two parts:

1. Find out the minimum changes you'd need to make to the HTML you get from SilverStripe that would satisfy the tool you're using.

I suggest you save each page(s) in question as static pages (HTML) from your browser into the top-level directory of your SS installation, and run those through the tool (ie Cynthia Says). Then make the changes you need, until the tool is satisfied. Once you have the required HTML in your static page, continue to the next step.

2. Find out how to make the necessary changes to SilverStripe, either by overriding stuff or hacking the core.

If you can show forum members the actual HTML you need, it'll be easier for someone (perhaps myself, although I'm not yet familiar with the areas of the source in question) to suggest the changes you need.

When you've made the changes, perhaps with others' help, your first test will be that the code you're getting from SS matches that in your static HTML files. The final test (noting Murphy's law) will be that the code from SS does actually satisfy the tool.

Hope this helps.

Toby

Avatar
tobych

Community Member, 97 Posts

7 January 2010 at 4:42pm

Ian,

I'm a bit weirded out by the fact that the metatag you're quoting has content-language in lower-case, but the code from SS is capitalised, as per the code below and in a 2.3 site I'm running. Also, I'm getting en-US, not just en. Are you sure the metatag you've quoting is actually coming from SilverStripe and isn't hardcoded in your template? Maybe I'm missing something here.

Also, I can't see

From a look at SiteTree, it looks like the content-language metatag is coming from the code:

		// get the "long" lang name suitable for the HTTP content-language flag (with hyphens instead of underscores)
		$currentLang = ($this->hasExtension('Translatable')) ? Translatable::get_current_locale() : i18n::get_locale();
		$tags .= "<meta http-equiv=\"Content-Language\" content=\"". i18n::convert_rfc1766($currentLang) ."\"/>\n";

SilverStripe's i18n class is discussed here:

http://doc.silverstripe.org/doku.php?id=i18n

and defined in sapphire/core/i18n.php

I can't see a current_lang() call in SiteTree, or a method defined in i18n. What version of SS are you running?

Toby "learning through helping" Champion

Avatar
Juanitou

Community Member, 323 Posts

7 January 2010 at 10:56pm

Hi Ian,

Concerning the meta tag, have you a line i18n::set_locale('en_GB'); in your _config.php?

Avatar
ianpiper

Community Member, 32 Posts

10 January 2010 at 5:57am

I changed the capitalised code in SiteTree.php (and everywhere else that had Content-Language with any capitalisation) to lower case in case it was the capitals that was distressing Cynthia. As you can see, it wasn't!

Regarding your two-stage strategy suggestion, that is a good idea. To some extent I had already been taking this approach: I was changing code, running the test again and then checking the errors against the html source of the page. I am pretty sure that the problem resides in the search form and I think I know roughly what it needs to be - I just can't figure out where in SS I should be making changes that would result in this html!

I will take another look at this now and maybe I will be able to provide the html that passes Cynthia says.

I am using SS 2.3 by the way.

Ian.

Avatar
ianpiper

Community Member, 32 Posts

10 January 2010 at 5:59am

> Concerning the meta tag, have you a line i18n::set_locale('en_GB'); in your _config.php?

No, I don't. Should I add this line?

Ian.
--

Avatar
tobych

Community Member, 97 Posts

10 January 2010 at 8:59am

I do think you should add the call to set your locale, as explained here:

http://doc.silverstripe.org/doku.php?id=i18n#setting_the_locale

Toby

Avatar
küchentiger

Community Member, 1 Post

11 January 2010 at 5:54pm

"Failure - Document does not contain a META element with the required name: language or language does not have a 'content' value."

The answer is:

<html lang="en">
...some stuff<title>Title</title>
<meta name="Language" content="en">

HTML must have the "lang" attribute and META Name is "Language" - without "Content"!

Go to Top