Drupal Coding Standards Essay

738 Words3 Pages
Drupal Coding Standards Drupal coding standards are independent of the version number, type and are "always-concurrent". All new code should follow current standards, regardless of initial type. Availed code found in an older version always needs updating, but it does not certainly have to be. Especially for larger code-bases (like Drupal core), updating the code of a previous version for your instant standards is too difficult a task. However, the code in current versions follows certain implementable standards. Do not squeeze coding standards updates/clean-ups into otherwise unrelated coding methods. Only touch code lines are always relevant. To update existing code for your accessed standards, create separate and devoted issues as well…show more content…
*/ function first_block_view($block_name = '') { if ($block_name == 'list_modules') { $list = module_list(); $theme_args = array('items' => $list, 'type' => 'ol'); $content = theme('item_list', $theme_args); $block = array( 'subject' => t('Enabled Modules'), 'content' => $content, ); return $block; } } ?> Indenting and Whitespace In Drupal <?php namespace This\Is\The\Namespace; use Drupal\foo\Bar; /** * Provides examples. */ class ExampleClassName { Or, for a non-class file (e.g., .module): <?php /** * @file * Provides example functionality. */ use Drupal\foo\Bar; /** * Implements hook_help(). */ function example_help($route_name) { Control Structures: Control structures include while, if, for, switch, etc. Here is a sample if statement, since it is the most complicated of them: if (condition1 || condition2) { action1; } elseif (condition3 && condition4) { action2; } else { defaultaction; } For switch statements: switch (condition) { case 1: action1; break; case 2: action2; break; default: defaultaction; } For do-while statements: do { actions; } while ($condition); Alternate control statement syntax for templates: (-- removed HTML --) (-- removed HTML

    More about Drupal Coding Standards Essay

      Get Access