D7 Theming
(Redirected from Theming)
Jump to navigation
Jump to search
Basics
- Building a new theme for Drupal 7 - IBM developerWorks
- Structure of the .info file
- Default .info values
- Assigning content to regions
- Creating a sub-theme
- JavaScript and jQuery
Modules
- Code per Node makes it possible to add custom CSS and Javascript per node, per block, and per content type. The code is stored in the database, but served from the file system. It also supports syntax highlighting with CodeMirror.
- CSS Injector allows administrators to inject CSS into the page output based on configurable rules. The CSS is added using Drupal's standard drupal_add_css() function and respects page caching, etc.
- JS injector - drupal_add_js() function and respects page caching, etc.
Development
- http://drupal.org/project/styleguide - gives Drupal elements to test css on
- http://drupal.org/project/devel_themer
- Using the Drupal Theme Developer Tool: YouTube: Theming Basics for Drupal
- Candidate page tpl name for particular custom content type entry - how to add devel themer override template suggestions in a custom content type.
Favicon
- https://drupal.org/project/favicon
- https://drupal.org/project/touch_icons
- https://drupal.org/project/sans_druplicon
Background
Backwards compatibility
Layout
Various different methods
Views Nodequeue
Blocks Panels
Context Spaces
Templates
- Overriding themable output - broad overview
- Core templates - the default template (.tpl.php) files provided by core in Drupal 7. variable and purpose docs are in the templates.
- Drupal 7 Template Suggestions - override templates in a more targeted way
- Default baseline variables
- modules--system--theme.api.php - Default theme implementations
- etc.
block
<div id="block-<?php print $block->module . '-' . $block->delta; ?>" class="<?php print $classes; ?> "<?php print $attributes; ?>> <?php print render($title_prefix); ?> <?php if ($block->subject): ?> <h2><?php print $block->subject ?></h2> <?php endif;?> <?php print render($title_suffix); ?> <div class="content"<?php print $content_attributes; ?>> <?php print $content ?> </div> </div>
Forms
For beyond basic content types field layouts;
- http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/7 - programmer's reference to the Drupal Form API
function milk_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'contact_node_form') { $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Send'), ); } }
- http://www.advomatic.com/blogs/jack-haas/notable-changes-to-theming-drupal-7 Notable changes to theming in Drupal 7] - Form Overrides section has another perspective on the basics
Responsive
Starter themes
Zentropy
- http://drupal.org/project/zentropy - good but no sass
Basic
Sasson
- http://drupal.org/project/sasson
- HTML5, responsive (content first), semantic grid (SASS/SCSS), CSS reset (normalize)
- v2 uses phamlp fork which bundles older Compass.
- v3 uses Ruby Sass
Automatic refresh feature: make sure GUI watch file is compiled .css, i.e., sites/example.org/files/sasson/webnetres/stylesheets/subtheme.css
Subthemes
drush sns [name] generate a subtheme
Use this Drush command to initalise a Sasson subtheme. Creates in sites/all, rather than respecting current path site context.
v2
sasson.info calls (to recheck)
- sasson/styles/boilerplate.css - h5bp.com/css
- sasson/styles/sasson.scss (.info call is to the processed .css, natch)
- @imports "css3", "960/grid", @import "base";
- https://github.com/nextmat/compass-960-plugin/blob/master/stylesheets/960/_grid.sass
- sasson/styles/layout/desktop-first/sasson-base.scss sets .page as 960px. for a 100% wrapper, add a div in subtheme/templates/page.tpl.php
@import "compass/css3"; // CSS3 mixins (http://compass-style.org/reference/compass/css3/) // @import "partials/mixins"; // Theme partial mixins (check your /partials directory)
v3
development branch, some of this might be out of date
Salsa grid
settings;
$container-width: 960px !default; $columns: 16 !default; $gutter-width: 20px !default; $flow: left !default; $opos: salsa-opos($flow); $box-sizing: border-box; $box-sizing-polyfill-path: "" !default; $ie7-support: false !default;
grid;
@include container; also, @include nested-container; @include grid(<$width> [<container>], [<$position>]); grid() is the heart of the layout system, it allows you to define grid-element's width and position. $width: - Can be unitless and represent the number of columns to span. - May have any kind of width unit (e.g. px, em, % etc.) and provide complete control over the element's with, even if not complying with the grid layout or if using a grid is not your cup of tea. $position: - Can be unitless and represent the column number the element starts on - May have any kind of width unit (e.g. px, em, % etc.) and provide complete control over the element's position, similar to absolute positioning only that elements are NOT removed from the normal flow. - May be 'row' to force a new grid row Examples: - Simple grid element spanning 4 columns starting from the 12th column @include grid(4, 12); - a 40% wide element pushed 60% off the grid's first column @include grid(40%, 60%); Nested grids - - You may provide $width as a simple fraction, so if you want an element to span 3 columns inside a 6 columns (nested) grid container, you'll probably use 3/6 as $width. - $position too. - note: 6/6 = 1 column, not 6 columns out of 6, use 100% instead. Example: 2 column grid element nested inside a 6 columns nested-container, starting from the 4th column. @include grid(2/6, 4/6);
Omega
Other
Lost a lot of theme info when old wiki crashed. Tod; rebuild up interesting theme list.
- https://drupal.org/project/unary - admin