Hi

why on this dev website i've block class name with numbers than letters ? so i can't use it to my css...
note websites are different but on multisite install
usually :

<div id="block-views-Formations_par_poles-block_2" class="block block-views odd pole_bloc_G clearfix">
  <div class="block-inner">

now :

<div id="block-views-738b11b0ba889cadf3ac3a104c7ff576" class="block block-views odd pole_bloc_G clearfix">
  <div class="block-inner">

if someone could help me to get back letters..

thanks

Comments

aiphes’s picture

more info, after exporting the view to a different install, class name still the same...so perhaps the origin is in the view, exemple : http://www.lycee-caucadis.com/node/4

an idea to fix this ?

thanks

merlinofchaos’s picture

Status: Active » Fixed

The classname of a block is based upon the 'delta' of the block. That is the unique identifier used to control which block it is. Drupal does this automatically.

Views uses the view name, a dash, and the display ID to identify blocks.

However, Drupal limits the delta to 32 characters. View names can be 32 characters and display ids can be 32 characters, meaning that the delta, for Views, can be up to 65 characters. That doesn't fit into 32. If the delta Views detects is > 32 characters, it converts this to an md5 hash so that it will fit.

In order to make the block delta not be a hash, you must ensure that the view, dash and display id combination will be 32 characters or less.

aiphes’s picture

ok but why its the first time in 2 years that i see that ? usually i've a name and the block id...but here nothing of that...strange isnt ?

merlinofchaos’s picture

Maybe this is the first time in 2 years you've had a view name + display id > 32 characters

aiphes’s picture

ok i'll see about the name..i missunderstood i guess...

EDIT: i think i understand...

affichage_formation_poles-block_1  => 34 caracters so title is changed in a number and class name is : block-views-738b11b0ba889cadf3ac3a104c7ff576
Formations_par_poles-block_2 => 29 caracters so name is not change and class name is : block-views-Formations_par_poles-block_2

am i right ?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

doublejosh’s picture

Hijacking...
Would also be lovely to have the view name among the classes without a theme layer solution ala:

function MYTHEME_preprocess_block(&$vars, $hook) {
  // Get the view name into the block classes.
  if ($vars['block']->module == 'views') {
    $delta = explode('-', $vars['block']->bid); // EX: views-articles-block_1, views--exp-articles-block_1
    $vars['classes_array'][] = ($delta[2] == 'exp') ? 'view-'. $delta[3] : 'view-'.$delta[1];
  }
}

Whop, found this post's rightful home: #1296768: How to add a CSS Class to the outer-most div of a block created using Views?

anybody’s picture

Version: 6.x-2.9 » 7.x-3.5
Status: Closed (fixed) » Active
StatusFileSize
new18.34 KB
new15.74 KB

The problem still exists for views blocks, even in the latest D7 version.

Screenshot of the problem is attached. The mail problem I see is that the section has no class regarding the view name. The numeric ID is dangerous in my eyes because:
1. Really really bad readable/understandable in Stylesheets for example (Comment required)
2. Has a "non persistent"
3. Can't be controlled by users.

Is it possible perhaps to set the class name given in the view or something like this?

Screenshots attached. The views export also:

$view = new view();
$view->name = 'block_ausstellerstimmen';
$view->description = 'Standard Views Struktur für webks Themes';
$view->tag = 'Ausstellerstimmen, Block';
$view->base_table = 'node';
$view->human_name = 'Block: Ausstellerstimmen';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['title'] = 'Ausstellerstimmen';
$handler->display->display_options['css_class'] = 'views_block_ausstellerstimmen';
$handler->display->display_options['use_ajax'] = TRUE;
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['use_more_text'] = 'mehr';
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['exposed_form']['options']['submit_button'] = 'Anwenden';
$handler->display->display_options['exposed_form']['options']['reset_button_label'] = 'Zurücksetzen';
$handler->display->display_options['exposed_form']['options']['exposed_sorts_label'] = 'Sortieren nach';
$handler->display->display_options['exposed_form']['options']['sort_asc_label'] = 'Aufsteigend';
$handler->display->display_options['exposed_form']['options']['sort_desc_label'] = 'Absteigend';
$handler->display->display_options['pager']['type'] = 'some';
$handler->display->display_options['pager']['options']['items_per_page'] = '1';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['style_plugin'] = 'list';
$handler->display->display_options['row_plugin'] = 'fields';
/* Verhalten, wenn keine Ergebnisse vorliegen: Global: Textbereich */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['label'] = 'Titelbild';
$handler->display->display_options['empty']['area']['empty'] = TRUE;
$handler->display->display_options['empty']['area']['content'] = 'Es gibt (noch) keine Einträge (zu den gewählten Filterkriterien).
Falls Filterkriterien gesetzt wurden, sollten diese möglicherweise angepasst werden.';
$handler->display->display_options['empty']['area']['format'] = 'full_html';
/* Feld: Inhalt: Inhalt */
$handler->display->display_options['fields']['body_1']['id'] = 'body_1';
$handler->display->display_options['fields']['body_1']['table'] = 'field_data_body';
$handler->display->display_options['fields']['body_1']['field'] = 'body';
$handler->display->display_options['fields']['body_1']['label'] = '';
$handler->display->display_options['fields']['body_1']['alter']['alter_text'] = TRUE;
$handler->display->display_options['fields']['body_1']['alter']['text'] = '<q>[body_1]</q>';
$handler->display->display_options['fields']['body_1']['element_label_colon'] = FALSE;
/* Feld: Inhalt: Quelle */
$handler->display->display_options['fields']['field_quelle']['id'] = 'field_quelle';
$handler->display->display_options['fields']['field_quelle']['table'] = 'field_data_field_quelle';
$handler->display->display_options['fields']['field_quelle']['field'] = 'field_quelle';
$handler->display->display_options['fields']['field_quelle']['label'] = '';
$handler->display->display_options['fields']['field_quelle']['element_type'] = 'em';
$handler->display->display_options['fields']['field_quelle']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_quelle']['hide_empty'] = TRUE;
/* Sortierkriterien: Inhalt: am Anfang von Listen */
$handler->display->display_options['sorts']['sticky']['id'] = 'sticky';
$handler->display->display_options['sorts']['sticky']['table'] = 'node';
$handler->display->display_options['sorts']['sticky']['field'] = 'sticky';
$handler->display->display_options['sorts']['sticky']['order'] = 'DESC';
/* Sortierkriterien: Global: Zufall */
$handler->display->display_options['sorts']['random']['id'] = 'random';
$handler->display->display_options['sorts']['random']['table'] = 'views';
$handler->display->display_options['sorts']['random']['field'] = 'random';
/* Filterkriterium: Inhalt: Typ */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
  'ausstellerstimme' => 'ausstellerstimme',
);
$handler->display->display_options['filters']['type']['group'] = 1;
/* Filterkriterium: Inhalt: Veröffentlicht */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;

/* Display: Block Random */
$handler = $view->new_display('block', 'Block Random', 'views_block_ausstellerstimmen');
$handler->display->display_options['display_description'] = 'Eine zufällige Ausstellerstimme je Seite';
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$translatables['block_ausstellerstimmen'] = array(
  t('Master'),
  t('Ausstellerstimmen'),
  t('mehr'),
  t('Anwenden'),
  t('Zurücksetzen'),
  t('Sortieren nach'),
  t('Aufsteigend'),
  t('Absteigend'),
  t('Titelbild'),
  t('Es gibt (noch) keine Einträge (zu den gewählten Filterkriterien).
Falls Filterkriterien gesetzt wurden, sollten diese möglicherweise angepasst werden.'),
  t('<q>[body_1]</q>'),
  t('Block Random'),
  t('Eine zufällige Ausstellerstimme je Seite'),
);
merlinofchaos’s picture

Status: Active » Closed (won't fix)

You apparently didn't pay attention.

If your view name + display name > 32 characters, you get an MD5. *there is no other alternative* because that is a length limit imposed by Drupal core. Your ONLY alternative is to use shorter view names and shorten your display IDs.

This cannot be 'fixed' to your satisfaction any other way.

brightbold’s picture

A HA! I've been wondering for years what caused this. Mystery solved ... and display names shortened.

anybody’s picture

My mistake. It was too late, as it seems. I should have read better. Sorry and thanks a lot for clarification.

Myko’s picture

Issue summary: View changes

И так если коротко то данная проблема заключаеться в том что иногда при попытке сделать теминг блока hook_theme_suggestion предлагает довольно странное имя для tpl что-то типа block-views-738b11b0ba889cadf3ac3a104c7ff576.tpl.php

Это происходит изза того что если имя вашей view + машинное имя блока > 32 символов то вместо имени береться MD5. Решаеться просто, делаете машинное имя вьюшки и блока покороче :)

Для поиска
- Друпал странное имя блока вьюс (view)
- Drupal view block stange name
- MD5 в имени блока