October 2014

Drupal Domain Access user 1 menu

Today when developing a Drupal site with the Domain Access module I had an interesting problem.
My site is set up with a custom theme and 2 domains.
My custom theme is using Zurb Foundation and so I had to override the main menu theme functions to add the Zurb classes.
This was easily done by implementing theme_links__system_main_menu, theme_menu_tree__main_menu__submenu and theme_menu_link__main_menu as outlined below (my theme name is nexus).

 function nexus_links__system_main_menu($variables) { 
$links = menu_tree_output(menu_tree_all_data(variable_get('menu_main_links_source', 'main-menu')));
$output = drupal_render($links);
return $output;
}

function nexus_menu_tree__main_menu__submenu($variables) {
return '<ul class="menu dropdown">' . $variables['tree'] . '</ul>';
}

function nexus_menu_link__main_menu($variables) {
$element = $variables['element'];
$sub_menu = '';
if ($element['#below']) {
$element['#below']['#theme_wrappers'][] = array('menu_tree__main_menu__submenu');
$sub_menu = drupal_render($element['#below']);
$element['#attributes']['class'][] = 'has-dropdown';
}
if (isset($element['#href']) && ($element['#href'] == $_GET['q'] || ($element['#href'] == '<front>' && drupal_is_front_page())) && (empty($element['#language']) || $element['#language']->language == $language_url->language)) {
$element['#attributes']['class'][] = 'active';
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}

The problem was that all node links assigned to the main menu would show up if you were logged in as user 1, even if they were not assigned to the current domain. Though, if you were not logged in the menu would appear correct and only show links assigned to the current domain.
This is obviously the correct behavior as the domain access module uses Drupal's node access system and the access system is bypassed for user 1.
At this point I could have switched...

Useful Three.js Links

Here is a list of useful Three.js links, mainly for my own reference but other may find it useful too.

  • Three.js homepage
  • Three.js documentation
  • Three.js Google+
  • Tutorials
    • Intro to WegGL with Three.js
  • Tools
    • Three.js template generator
  • Articles
    • The Hobbit Experience - a Good article to read up on three.js performance optimisations

  • Demos
    • Three.js examples
    • stemkoski.github.io