2014-05-02 91 views
0

Drupal 7附加类添加到页面Drupal 7附加类添加到页面

在Drupal 7中,某些时候视图可以在此处添加类contextual-links-region。 因此,它使上下文链接显示在所有视图中,而不仅仅是鼠标移动的视图。

这里/如何在这里添加班级? 如何从#page中删除此类?

回答

0

我不会推荐你这样做,但如果你仍然需要它,那么类“contextual-links-region”是由views模块使用JavaScript添加的。

从视图模块:

/** 
* Implements MODULE_preprocess_HOOK(). 
*/ 
function views_preprocess_html(&$variables) { 
    // If the page contains a view as its main content, contextual links may have 
    // been attached to the page as a whole; for example, by views_page_alter(). 
    // This allows them to be associated with the page and rendered by default 
    // next to the page title (which we want). However, it also causes the 
    // Contextual Links module to treat the wrapper for the entire page (i.e., 
    // the <body> tag) as the HTML element that these contextual links are 
    // associated with. This we don't want; for better visual highlighting, we 
    // prefer a smaller region to be chosen. The region we prefer differs from 
    // theme to theme and depends on the details of the theme's markup in 
    // page.tpl.php, so we can only find it using JavaScript. We therefore remove 
    // the "contextual-links-region" class from the <body> tag here and add 
    // JavaScript that will insert it back in the correct place. 
    if (!empty($variables['page']['#views_contextual_links_info'])) { 
    $key = array_search('contextual-links-region', $variables['classes_array']); 
    if ($key !== FALSE) { 
     unset($variables['classes_array'][$key]); 
     // Add the JavaScript, with a group and weight such that it will run 
     // before modules/contextual/contextual.js. 
     drupal_add_js(drupal_get_path('module', 'views') . '/js/views-contextual.js', array('group' => JS_LIBRARY, 'weight' => -1)); 
    } 
    } 
} 

您可以通过实现hook_js_alter()

删除JS文件
相关问题