Block styles feature

Step 1 Open the .info file and define the block styles you want the theme to support.
	block_styles[raw] = 'Raw'
	block_styles[xhtml] = 'Xhtml'
	block_styles[rounded] = 'Rounded'
	block_styles[badge] = 'Badge'
Step 2 Open /tpl folder and create .tpl.php files for the block styles (mark-up) defined in Step 1)
Rule for extending the block template (mark-up):

In Drupal the mechanism to render the style of a block is very sophisticated. They are controlled in block template files. The template for a certain block is declared in an array called theme_hook_suggestions, with ascending priority. For example let's take the block "search form", then the theme_hook_suggestions array has following value:[block__header, block__search, block__search__form].

In detail it means:

  • Drupal will give highest priority to the template block--search--form.tpl.php
  • If the above template does not exist, it will use block--search.tpl.php
  • Further if not available, it will search for template block--header.tpl.php
  • If all the above templates aren't available, it uses the general block.tpl.php

With our block styling feature, Nucleus inherits this theming mechanism in Drupal and will add block templates into array theme_hook_suggestions to render a certain style for a given block. For the same block "search form" if a user chooses style = rounded, then array theme_hook_suggestions will have following values: [block__rounded, block__header, block__header__rounded, block__search, block__search_rounded, block__search__form, block__search__form_rounded]

Step 3 Open file .info file and define the extended classes which you want the theme to support.
	block_extend_classes[badge-hot] = 'Badge Hot'
	block_extend_classes[badge-new] = 'Badge New'
	block_extend_classes[badge-pick] = 'Badge Pick'
	block_extend_classes[badge-top] = 'Badge Top'
	block_extend_classes[blue-color] = 'Blue Color'
	block_extend_classes[white-color] = 'White Color'
	block_extend_classes[yellow-color] = 'Yellow Color'
	block_extend_classes[padding] = 'Padding'
	block_extend_classes[no-padding] = 'No Padding'
Step 4 Add relationship of the block styles and extend classes using the above rule. You declare that some classes will support certain mark-up only.
	block_extended_class_groups[group_name][group_title] = 'group title'
	block_extended_class_groups[group_name][supported_styles] = 'list style seperated by comma'  
	block_extended_class_groups[group_name][classes] = 'list class seperated by comma'

In case you do not define value for [supported_styles] then it will support all styles except for ‘raw’. Styles list were supported by classes list, when user choose a style in the ‘supported_styles’ they’ll be able to select only 1 class in a group.

	block_extended_class_groups[group_1][group_title] = 'Badge Block Styles'
	block_extended_class_groups[group_1][supported_styles] = 'badge, rounded'
	block_extended_class_groups[group_1][classes] = 'badge-hot, badge-new, badge-pick, badge-top'
meaning ‘badge’, ‘rounded’ styles were supported by ‘badge-hot’, ‘badge-new’, ‘badge-pick’, ‘badge-top' classes
	block_extended_class_groups[group_2][group_title] = 'Color Block Styles'
	block_extended_class_groups[group_2][classes] = 'blue-color, white-color, yellow-color'

meaning all styles except ‘raw’ were supported by ‘blue-color’, ‘white-color’, ‘yellow-color’ classes
others: the classes don’t exist in any group (‘padding’, ‘no-padding’) will be in a same group and support all style except ‘raw’.