Friday, December 28, 2012

Accessible “Read More” Links

When there are a bunch of “read more” links on a page, it is usually fairly obvious from visual cues what the “read more” refers to. However, when screen reader users encounter a bunch of “read more” links on a page, it is not always obvious which part of the page each “read more” link refers to. A simple solution is to use a bit more descriptive text than simply “read more” and use CSS to hide the additional text. In this example the following code is used.

<p><a href="#">Read more <span class="offscreen">About NC State</span></a></p>
This is the CSS rule.

.offscreen {
  • The off-screen text needs to be included in the <a> as well, otherwise it won’t be read correctly by screen readers.
  • You cannot use the CSS rule display:none or visibility:hidden as that will make the content invisible to screen reader users.
  • This code is not unique to me. It is the compilation of different examples I have seen in various accessibility forum posts. I just want to put this example in writing for others.

Thursday, December 13, 2012

Autocomplete off - (Custom Module)

'Autocomplete off' Module work on these forms - user login, user profile, user_register, user_pass.

Download Module

Form Autocomplete off

function autocomplete_form_user_login_alter(&$form, &$form_state) {
$form['#attributes']['autocomplete'] = 'off';

Monday, December 10, 2012

Clear cache URL or menu link

Create a new page, with the input filter set to a filter that can run PHP. Then use the following snippet, which was shamelessly yanked from devel.module:
* 2008 Jun 26
* The code submitted by dharmanerd in his comment probably
* works better than the original I had, so I've modified this
* to match his code.
* The original code for this was shamelessly yanked from
* `devel.module`; it was the function `devel_cache_clear()`.

// only allow site administrators to visit this page:
if (!user_access('administer site configuration')) {
else {
$tables = array(
  foreach (
$tables as $table) {
cache_clear_all('*', $table, TRUE);
drupal_set_message('Cache cleared.');
Set a URL path for this page (perhaps 'cache_clear') so that you can clear the cache easily. Clear the cache by visiting the URL or add the path to a menu link(watch your permissions).
Code Notes:
  • The drupal_goto at the end of the page will redirect you to either the destination or to the main page of your site; you can change this if you wish.
  • If this code is in a block that was visible on all pages (i.e. including the home page) then the home page would endlessly redirect to itself, breaking your site. The answer is to remove the drupal_goto() from the code, then all caches would be cleared on every page view.
  • Because of the drupal_goto, you can never actually visit this page; you can edit it through the admin/content/node page.
  • You may have to remove the path parameter to the function call drupal_goto, because it gets added to the homepage URL.
  • If you missed some part of the code, which makes the site inaccessible you can remove the code through phpmyadmin, by browsing the block table and editing the appropriate block you created.

only show translated menu items into current language (Drupal 8)

function MY_THEME_preprocess_menu(&$variables) {   if ($variables['menu_name'] == 'brancott-header-menu') {    $langu...