Index: block_class.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/block_class/block_class.install,v retrieving revision 1.4.4.3 diff -u -p -r1.4.4.3 block_class.install --- block_class.install 31 Jan 2010 21:09:55 -0000 1.4.4.3 +++ block_class.install 3 Dec 2010 18:51:01 -0000 @@ -33,6 +33,12 @@ function block_class_schema() { 'not null' => TRUE, 'description' => t('String containing the classes for the block.'), ), + 'css_id' => array( + 'type' => 'varchar', + 'length' => '32', + 'not null' => TRUE, + 'description' => t('String containing the ID for the block.'), + ), ), 'primary key' => array('module', 'delta'), ); @@ -55,3 +61,26 @@ function block_class_install() { function block_class_uninstall() { drupal_uninstall_schema('block_class'); } + + +/** + * Implementation of hook_update_N(). Alters the structure of the + * block_class schema. + * + * @return array The results of the updates. + * + */ +function block_class_update_6100() { + $status = array(); + + $spec = array( + 'type' => 'varchar', + 'length' => '32', + 'not null' => TRUE, + 'description' => t('String containing the ID for the block.'), + ); + + db_add_field($status, 'block_class', 'css_id', $spec); + + return $status; +} Index: block_class.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/block_class/block_class.module,v retrieving revision 1.3.4.7 diff -u -p -r1.3.4.7 block_class.module --- block_class.module 31 Jan 2010 21:28:10 -0000 1.3.4.7 +++ block_class.module 3 Dec 2010 18:51:01 -0000 @@ -20,12 +20,14 @@ function block_class_preprocess_block(&$ else { $variables['block_classes'] = block_class($variables['block']); } + + $variables['block_html_id'] = block_class($variables['block'], 'css_id'); } -function block_class($block) { +function block_class($block, $type = 'css_class') { $attributes = block_class_attributes($block); - return check_plain($attributes->css_class); + return check_plain($attributes->$type); } @@ -34,7 +36,7 @@ function block_class_attributes($block, // If we've not fetched the data, or we're being reset, fetch all the data: if (is_null($blocks) || $reset) { - $result = db_query("SELECT css_class, module, delta FROM {block_class}"); + $result = db_query("SELECT css_class, css_id, module, delta FROM {block_class}"); while ($row = db_fetch_object($result)) { $blocks[$row->module][$row->delta] = $row; } @@ -47,6 +49,7 @@ function block_class_attributes($block, else { $undef = (object) NULL; $undef->css_class = ''; + $undef->css_id = ''; return $undef; } } @@ -71,6 +74,12 @@ function block_class_form_alter(&$form, '#default_value' => $attributes->css_class, '#description' => t('Separate classes with a space.'), ); + $form['block_class']['css_id'] = array( + '#type' => 'textfield', + '#title' => t('CSS ID'), + '#default_value' => $attributes->css_id, + '#description' => t('Enter the CSS ID.'), + ); $form['#submit'][] = 'block_class_form_submit'; } @@ -79,15 +88,16 @@ function block_class_form_alter(&$form, function block_class_form_submit($form, &$form_state) { if ($form_state['values']['form_id'] == 'block_admin_configure' || $form_state['values']['form_id'] == 'block_add_block_form') { - if (isset($form_state['values']['css_class']) && user_access('administer blocks')) { + if ((isset($form_state['values']['css_class']) || isset($form_state['values']['css_id'])) && user_access('administer blocks')) { $module = $form_state['values']['module']; $delta = $form_state['values']['delta']; $class = $form_state['values']['css_class']; + $id = $form_state['values']['css_id']; db_query("DELETE FROM {block_class} WHERE module = '%s' AND delta = '%s'", $module, $delta); - if (!empty($class)) { - db_query("INSERT INTO {block_class} (module, delta, css_class) VALUES ('%s', '%s', '%s')", $module, $delta, $class); + if (!empty($class) || !empty($id)) { + db_query("INSERT INTO {block_class} (module, delta, css_class, css_id) VALUES ('%s', '%s', '%s', '%s')", $module, $delta, $class, $id); } } }