205
Drupal Theming Krimson Hans Rossel en Jan-Yves Vanhaverbeke 17/8/2011 en 14/9/2011 Hans Rossel - [email protected]

Drupal7 Theming

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Drupal7 Theming

Drupal Theming KrimsonHans Rossel en Jan-Yves Vanhaverbeke17/8/2011 en 14/9/2011

Hans Rossel - [email protected]

Page 2: Drupal7 Theming

Theme Documentation

• Theme guide: http://drupal.org/theme-guide/6-7

• Update modules: http://drupal.org/update/modules/6/7

• Update themes: http://drupal.org/update/theme/6/7

• Theme Forum: http://drupal.org/forum/3

• Theme layer: http://drupal.org/node/933976

• #drupal-themes on irc.freenode.net

• http://lists.drupal.org/mailman/listinfo/themes

Page 3: Drupal7 Theming

Hulpmiddelen

• Firefox: Firebug, webdeveloper toolbar, pixelperfect, xrefresh, colorzilla, webaim

• Devel en devel_themer

Page 4: Drupal7 Theming

Voorbereiding

Wireframes Photoshop design

Page 5: Drupal7 Theming

SchermformatenStandaard 1024x768• Favorieten open?• Bovenmenu aftrekken• Toolbar• Laptop widescreen• Mobile, nieuwere 1152x… >500 verschillende formaten• Verschillen mac/pc• Verschillen IE en Firefox

Responsive Webdesign: http://www.alistapart.com/articles/responsive-web-design/

• Oude methode: javascript styleswitcher• Nieuw: media queries

Page 6: Drupal7 Theming

Drupal 7 core Themes: Appearance

Page 7: Drupal7 Theming

Theme folder

Core: /themesContrib: /sites/all/themesCustom: /sites/default/themes

(tenzij bij multisite dan idem contrib)

Page 8: Drupal7 Theming

Soorten themes

• Core• Contrib• Custom• Starter/base• Admin• Html5

Page 9: Drupal7 Theming

SUBTHEMEEEN THEME

OP BASIS VANEEN ANDER THEME

Page 10: Drupal7 Theming

Subtheme van een bestaand theme

.info file:

Toevoegen:base theme = garland of bartik

Opgelet: Pas nooit rechtstreeks een core of ander theme aan. Voordeel om via base theme te werken is dat je updates van het

base theme kunt implementeren.

Starter themes zoals Zen en Fusion zijn specifiek ontwikkeld om als base theme gebruikt te worden.

Page 11: Drupal7 Theming

Starter Themes

• http://drupal.org/project/zen

• www.drupal.org/project/fusion

• www.drupal.org/project/adaptivetheme (html 5)

• www.drupal.org/project/omega (html 5)

• http://drupal.org/project/framework

Speciaal: clean html code

• http://drupal.org/project/mothership: clean html

• http://drupal.org/project/stark: drupal default markup

Page 12: Drupal7 Theming

ZEN Theme

● www.drupal.org/project/zen● Net als Garland gebaseerd op de

http://www.positioniseverything.net/articles/jello.html Jello Mold techniek: negatieve marges

● Voordelen● Enorm goede documentatie in comments● Extra functies (theme settings, block editing)● Perfect full option hackable via subtheme

Handleiding: http://drupal.org/node/226507

Page 13: Drupal7 Theming

Mooie code, lelijk theme

Page 14: Drupal7 Theming

Een Zen subtheme - #226507

1.Kopieer STARTERKIT en hernoem het

2..info: mijntheme.info + verwijzingen

3.CSS

1.layout-liquid.css of layout-fixed.css layout.css→

2.zen.css mijntheme.css→

3.Optie: html-elements.css + ;weghalen uit .info file

4.Kopieer tpl.php files indien gewenst

Page 15: Drupal7 Theming

CSS Framework Starter Themes

css frameworks zijn erg handig om snel complexe layouts te maken die standard compliant zijn. Bekende voorbeelden zijn www.blueprintcss.org en www.960.gs. Ze bestaan uit een reset css, rapid prototyping grid css en css voor standaard elementen. Bij Drupal vind je de volgende themes die hierop gebaseerd zijn:

• http://drupal.org/project/fusion + skinr (bijvoorbeeld acquia marina theme of Acquia prosper shopping cart theme)

• http://drupal.org/project/blueprint

• http://drupal.org/project/ninesixty

• http://drupal.org/project/ninesixtyfluid

Page 16: Drupal7 Theming

Admin Themes

Nu er erg wordt gewerkt aan het verbeteren van de User Experience en Usability van Drupal zijn er recent heel wat mooie admin themes beschikbaar. Ze zijn bedoeld als theme voor de backend van Drupal en je stelt ze in als beheertemplate. Zo krijg je een perfecte scheiding tussen backend en frontend.

• http://drupal.org/project/admin (module!)

– Rubik: icons: http://code.developmentseed.org/rubik

– Tao base theme:http://code.developmentseed.org/tao

• http://drupal.org/project/rootcandy

• http://drupal.org/project/seven (backport van d7 theme)

Page 17: Drupal7 Theming

Ontwerp je eigen subtheme

template.php: theme function overrides die voor alle themes van belang zijn

Overnemen zaken van andere starter themes:

• Zen theme: body classes

• Zen theme: tabs en messages

• Tao: css reset

Page 18: Drupal7 Theming

Standaardstijlen

Page 19: Drupal7 Theming
Page 20: Drupal7 Theming
Page 21: Drupal7 Theming
Page 22: Drupal7 Theming

EEN DRUPAL 7 THEME “FROM SCRATCH”

Page 23: Drupal7 Theming

Theme CSS

• Drupal voegt heel wat html met id's en classes toe. Probeer zoveel mogelijk met css op te lossen. De html wijzigen van Drupal is een stuk moeilijker.

• Werk je html/css template niet volledig in detail af. Afwerking css van blokken, zoekbox, menu's hou je best voor nadat je de template in Drupal hebt gebracht

• Name collision: Drupal voegt html toe met .menu, .content, .links, .block. Gebruik die classes niet in je eigen template anders krijg je een conflict.

Page 24: Drupal7 Theming

HTML/css Prototypewww.styleshout.com / www.oswd.org

vectorlover html/css prototypehttp://www.styleshout.com/free-templates.php?page=2

Page 25: Drupal7 Theming
Page 26: Drupal7 Theming

.

Page 27: Drupal7 Theming
Page 28: Drupal7 Theming

Theme files

.info (definition file)

screenshot.png

Css, js, images

page.tpl.php, node.tpl.php: • html met dynamische (php) stukken

template.php: (geavanceerde) php code

Page 29: Drupal7 Theming
Page 30: Drupal7 Theming

Regions

regions[header] = Headerregions[help] = Help (d6:$help)regions[page_top] = Page top (d6:$closure)regions[page_bottom] = Page bottom (d6:$closure)regions[highlight] = Highlighted (d6:$mission)regions[featured] = Featuredregions[content] = Content (d7:main page content is block!)regions[sidebar_first] = Sidebar first (d6:left)regions[sidebar_second] = Sidebar second (d6:right)regions[footer] = Footer (d6:$footer_message)

In D7: regions_hidden[] = naam van de regio die je wil verbergen in de blocks overview page (default zijn verborgen page_top en page_bottom)

Blocks overview page: Demonstrate Block regions

Page 31: Drupal7 Theming

Theme folder

Maak folder: sites/default/themes/vectorlover

Voeg je index.html, css, images van je statische template toe

Page 32: Drupal7 Theming

.info fileMaak een vectorlover.info file

name = vectorlover

description = A very nice theme

(package nooit gebruiken: Core themes hebben hier “core” in D7 zodat de update manager ze kan herkennen)

version = 1.0

core = 7.x

engine = phptemplate

stylesheets[all][] = css/vectorlover.css

stylesheets[all][] = css/custom.css

scripts[] = scripts/scripts.js

Page 33: Drupal7 Theming

Template files• /modules/system

– html.tpl.php : Bevat DOCTYPE, <head> met RDFa, page_top en page_bottom regions en de content region waarin page.tpl.php wordt geprint. Meestal ga je html.tpl.php niet overnemen in je eigen theme. Zie ook http://api.drupal.org/api/function/template_preprocess_html/7 om variabelen hiervan aan te passen.

– page.tpl.php: <body> van index.html

• Hernoem index.html naar page.tpl.php en verwijder alles behalve wat tussen de <body> tags zit

Page 34: Drupal7 Theming

Theme activeren• screenshot.png toevoegen (294px × 219px)

• Appearance tab: theme activeren

• Telkens je een nieuw tpl.php bestand toevoegd aan een theme: clear theme registry

– Clear cache button bij Performance settings

– D7: drupal_theme_rebuild() in template.php (opgelet! Achteraf uitschakelen of serieuse problemen met performance)

– Vinkje “Rebuild Theme Registry on every page” bij bepaalde themes

Page 35: Drupal7 Theming

Theme Registry

http://drupal.org/node/173880

De theme registry moet leeggemaakt worden telkens als je een template file toevoegt (niet bij activatie theme)

• Via Prestatie > Clear cache (alle cache!)

• Via admin_menu of devel module link

• Via drush cc (optie 2)

Page 36: Drupal7 Theming

Functie clear theme registry

Wordt best conditioneel toegevoegd via een setting voor het theme. Performance problemen indien dit blij live site vergeten wordt uit te schakelen

// Rebuild .info data.

system_rebuild_theme_data();

// Rebuild theme registry.

drupal_theme_rebuild();

Page 37: Drupal7 Theming

Dynamische content copiëren en plakken

Page 38: Drupal7 Theming

First sidebar (zijkolom regio)

• Alle regio's die je definieert in je .info bestand moeten geprint worden in html.tpl.php en page.tpl.php om hun juiste plaats op de pagina te bekomen.

Page 39: Drupal7 Theming

Main menu (hoofdnavigatie)

• To meet Web Content Accessibility Guidelines (WCAG) requirements, HTML headings should be used before all content sections, which includes lists of links such as menus. The headers ensure that there is a quick way for assistive technology users to browse through the content

Page 40: Drupal7 Theming

Variabelen

• Heel wat beschikbare variabelen

• Bekijken via devel of print_r($vars) in template

• Definitie van de variabelen in includes/theme.inc en de respectievelijke modules

Page 41: Drupal7 Theming

THEME AANPASSEN OP MAAT

Page 42: Drupal7 Theming

CSS in Drupal themes

• Vermijd overlapping van css classes door .content, .menu, .links, .block niet te gebruiken

• Drupal heeft reeds enorm veel classes en id's voorgedefinieerd, oa body classes die al heel wat context leveren om te stylen

• Via bepaalde modules kunnen extra css classes toegevoegd worden via de interface: views, ds, ...

Page 43: Drupal7 Theming

Css aanpassen

• Stylesheet toevoegen in (sub) theme via .info file

• drupal_add_css om (conditioneel) css toe te voegen via template.php of een module

• hook_css_alter om css aan te passen

Page 44: Drupal7 Theming

Css toevoegen via .info

; Add a style sheet for all media

stylesheets[all][] = theStyle.css

; Add a style sheet for screen and projection media

stylesheets[screen, projection][] = theScreenProjectionStyle.css

; Add a style sheet for print media

stylesheets[print][] = thePrintStyle.css

Page 45: Drupal7 Theming

Media queries

.info filestylesheets[screen and (max-width: 600px)][] = screen-600.css

In css bestand:@media screen and (max-device-width: 600px) {

//aanpassingen voor kleine toestellen

}

Page 46: Drupal7 Theming

.element-invisible in Bartik

Page 47: Drupal7 Theming

Accessibility: Css clip

Probleem: hide content except for screen-readers • display:none maakt de content onzichtbaar voor screen-readers• Negative text-indent heeft problemen met RTL talen

.element-invisible { clip:rect(1px, 1px, 1px, 1px); position:absolute !important;}

Achtergrond:http://adaptivethemes.com/using-css-clip-as-an-accessible-method-of-hiding-content

Page 48: Drupal7 Theming

drupal_add_css

• http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_add_css/7

• drupal_add_css(path_to_theme() . '/css/ie/ie-7.css', array('group' => CSS_THEME, 'weight' => 115, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));

• drupal_add_css(drupal_get_path('module', 'dashboard') . '/dashboard.css');

Page 49: Drupal7 Theming

Verwijzen naar actieve theme

• In template $directory

• path_to_theme()

• drupal_get_path('theme', 'bartik')

Page 50: Drupal7 Theming

Reset css

• Nodig? http://css-class.com/test/css/defaults/UA-style-sheet-defaults.htm

• Reset.css + base.css

• Alternatief: normalize.css, initial.css, html5 boilerplate

• Dient eerst te komendrupal_add_css(path_to_theme() . '/css/reset.css', array('group' => CSS_SYSTEM - 1,

'preprocess' => FALSE));

Page 51: Drupal7 Theming

IE csstemplate.php (example Bartik theme)

Gebruik: functie abc_preprocess_html(&$vars)

Page 52: Drupal7 Theming

IE css via module

• Issue: in .info file? Zie http://drupal.org/node/522006

• Via module: http://drupal.org/project/conditional_styles

– stylesheets-conditional[lt IE 7][all][] = ie6-and-below.css

– stylesheets-conditional[IE 9][all][] = ie9.css

– stylesheets-conditional[IE][print][] = ie-print.css

Page 53: Drupal7 Theming

Hook_css_alter

http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_css_alter/7

<?phpfunction abc_css_alter(&$css) { // Remove defaults.css file. unset($css[drupal_get_path('module', 'system') .

'/defaults.css']);}?>

Page 54: Drupal7 Theming

hook_css_alter

Page 55: Drupal7 Theming

Remove multiple css files

<?php

function THEMENAME_css_alter(&$css) {

$exclude = array(

'misc/vertical-tabs.css' => FALSE,

'modules/aggregator/aggregator.css' => FALSE,

'sites/all/modules/date/date_popup/themes/datepicker.1.7.css' => FALSE,

'misc/ui/jquery.ui.theme.css' => FALSE,

);

$css = array_diff_key($css, $exclude);

}

?>

Page 56: Drupal7 Theming

Override css

/**

* Implements hook_css_alter().

*/

function seven_css_alter(&$css) {

// Use Seven's vertical tabs style instead of the default one.

if (isset($css['misc/vertical-tabs.css'])) {

$css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';

}

if (isset($css['misc/vertical-tabs-rtl.css'])) {

$css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs-rtl.css';

}

// Use Seven's jQuery UI theme style instead of the default one.

if (isset($css['misc/ui/jquery.ui.theme.css'])) {

$css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';

}

}

Page 57: Drupal7 Theming

HTML Aanpassen

• Via .tpl.php file: template file aanpassen of dupliceren in een template suggestion

• Via theme_ functie in template.php: function override

• Via preprocess en process functies in template.php: variabelen aanpassen

Page 58: Drupal7 Theming

tpl.php files in d7

Page 59: Drupal7 Theming

HTML wijzigenTemplate overrides

• Copieer om het even welk tpl.php bestand dat je vindt in een module naar je de map van je theme

• Doe aanpassingen in de html naar wens

• Maak de cache (theme registry) leeg

Voorbeeld:

search-result.tpl.php in /modules/search

Page 60: Drupal7 Theming

page.tpl.phpFrontpage page--front.tpl.php

Vermijd zoveel mogelijk meerdere page.tpl.php templates te hebben. Gebruik css of preprocess variabelen in template.php.

Op pad (url geen alias)

page--node-edit.tpl.php of page--node-add.tpl.php > page--node-1.tpl.php > page--node.tpl.php > page.tpl.php

page--blog.tpl.php, page--viewpagename.tpl.php, page--admin.tpl.php, page--admin-build-block.tpl.php, page--civicrm.tpl.php, page--googlemap.tpl.php

Nieuw in D7: % integer wildcardpage--user.tpl.php > page--user--%.tpl.php > page--user--1.tpl.php

Page 61: Drupal7 Theming

node.tpl.php

Copieer de originele node.tpl.php van /modules/nodePer content typenode--blog.tpl.php

node--forum.tpl.php

node--page.tpl.php

node--ccknews-content-type.tpl.php

D6: Opgelet: je moet steeds een gewoon node.tpl.php bestand hebben in je theme folder als je het wil overriden. In D7 deze bug is opgelost.

Page 62: Drupal7 Theming

Block template files

Page 63: Drupal7 Theming

block.tpl.php

block.tpl.php

block--region.tpl.php

block--module.tpl.php

Block--module--delta.tpl.php

Page 64: Drupal7 Theming

Belangrijkste andere tpl.php

●In /modules/system● region.tpl.php● maintainance-page.tpl.php● html.tpl.php

●In /modules/node ●node.tpl.php●In /modules/field ●field.tpl.php●In /modules/comment

●comment.tpl.php

●In /modules/block ●Block.tpl.php

Page 65: Drupal7 Theming

Theme hook suggestions

function abc_preprocess_page(&$vars, $hook) {

print_r($vars['theme_hook_suggestions']);

}

Array (

[0] => page__node

[1] => page__node__%

[2] => page__node__1

)

Page 66: Drupal7 Theming

Theme function overrides

Page 67: Drupal7 Theming

HTML wijzigen viaTheme overrides

Als er geen tpl.php beschikbaar is, dan zit de html in een theme_ functie

• Zoek de theme_functie in je module of via api.drupal.org, api.lullabot.com of http://drupalcontrib.org (contrib)

• Copieer en plak de functie in template.php en vervang theme_ met naamvanjetheme_ (niet meer phptemplate_ zoals in D6)

• Pas de html aan naar wens

Page 68: Drupal7 Theming

theme_breadcrumb()

Page 69: Drupal7 Theming

theme_breadcrumb()

Page 70: Drupal7 Theming

BASIS THEME FUNCTIES

Page 71: Drupal7 Theming

Themeable functions

Handige functies voor links, lijsten, …

–http://api.drupal.org/api/group/themeable/6

Page 72: Drupal7 Theming

L functie: een link maken

● http://api.drupal.org/api/drupal/includes--common.inc/function/l/7

● Vorm: l($text, $path, $options = array());

● Eenvoudig voorbeeld

l(t('klik hier'), “node/1”);

● Voorbeeld uit blog module

l(t('View recent blog entries'), "blog/$user->uid", array('attributes' => array('title' => t("Read @username's latest blog entries.", array('@username' => $user->name)))));

Page 73: Drupal7 Theming

theme_item_list: een lijst

● http://api.drupal.org/api/function/theme_item_list/6

● Vorm: theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL)

● Voorbeeld<?php $items = array('jan','piet','joris');print theme('item_list', $items, NULL, 'ul', array('class' => 'mijn-lijst', 'id' => 'de-lijst')) ?>

Page 74: Drupal7 Theming

theme_links

● http://api.drupal.org/api/function/theme_links/6

● Vorm: theme_links($links, $attributes = array('class' => 'links'))

● Voorbeeldtheme('links', $primary_links, array('class' => 'links primary-links', 'id' => 'primary'))

Page 75: Drupal7 Theming

Preprocess en processfuncties

Page 76: Drupal7 Theming

Template.php

Page 77: Drupal7 Theming

Drupal paden, classes voor css

Standaard: node/nid Opvragen via:

http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/arg/7 Voorbeeld

Drupal path: node/11<?php print arg(0); ?> geeft node<?php print arg(1); ?> geeft 11

<?php if (arg(2) == 'edit') { echo $content; }

Page 78: Drupal7 Theming

Node controleren

function themename_preprocess_page(&$variables) {

$variables['ifnode'] = ( (arg(0) == 'node') && is_numeric(arg(1)) ) && (arg(2) != 'edit' || arg(2) != 'delete');

}

Page 79: Drupal7 Theming

hook_preprocess_html

Page 80: Drupal7 Theming

hook_preprocess_html

Page 81: Drupal7 Theming

hook_preprocess_html

Page 82: Drupal7 Theming

hook_html_head_alter()

Page 83: Drupal7 Theming

hook_html_head_alter()

Page 84: Drupal7 Theming

hook_html_head_alter()

Page 85: Drupal7 Theming

hook_html_head_alter()

Page 86: Drupal7 Theming

hook_preprocess_page

Page 87: Drupal7 Theming

hook_preprocess_page

Page 88: Drupal7 Theming

hook_preprocess_page

Page 89: Drupal7 Theming

Nieuwsbrief tpl.php

/* * Newsletter: make separate template files for html and page if

node type is nieuwsbrief */function vai_preprocess_page(&$variables) { if ($variables['node']->type == 'nieuwsbrief') { $variables['theme_hook_suggestions'][] =

'page__nieuwsbrief'; }}

Page 90: Drupal7 Theming

hook_preprocess_page

Page 91: Drupal7 Theming

hook_preprocess_node

Page 92: Drupal7 Theming

hook_preprocess_node

Page 93: Drupal7 Theming

hook_preprocess_node

Page 94: Drupal7 Theming

hook_preprocess_node

Page 95: Drupal7 Theming

hook_preprocess_node

Page 96: Drupal7 Theming

hook_preprocess_node

Page 97: Drupal7 Theming

hook_process_node

Page 98: Drupal7 Theming

hook_preprocess_block()

Page 99: Drupal7 Theming

Theme hook suggestions voor blockin hook_preprocess_block

Page 100: Drupal7 Theming

Block admin pagina

function seven_preprocess_block_admin_display_form(&$vars) {

// List of modules which are allowed on the block page

$show = array(

'block',

);

// Scan through each disabled block entry and remove ones that aren't needed.

foreach ($vars['block_listing']['-1'] as $key => $disabled) {

$type = explode('_', $key);

if (!in_array($type[0], $show)) {

unset($vars['block_listing']['-1'][$key]);

}

}

}

Page 101: Drupal7 Theming

URL Aliassen opvragenZie:

http://api.drupal.org/api/drupal/includes--path.inc/function/drupal_get_path_alias/7 en http://www.php.net/manual/en/reserved.variables.get.php

<?php // $_GET['q'] geeft node/nid en explode() splitst de string op bij '/' en plaatst de

stukken in een array $path_pieces = explode('/', drupal_get_path_alias($_GET['q']));

// dus als het pad is /abc/def, $path_pieces is dan Array ( [0] => abc, [1] => def ) // Dus, $path_pieces[0] geeft 'abc' print $path_pieces[0];?>

Mogelijkheden:• Via preprocess toevoegen aan body classes

Page 102: Drupal7 Theming

Render API

Page 103: Drupal7 Theming

Render API

• $page array bevat regios, blokken, ...: flexibel spelen met content via hook_page_alter()

• Meer info

– http://www.archive.org/details/ExplorethegloryofDrupal7simprovedrenderandthemingsystems

– http://www.archive.org/details/PageRenderDrillDownInDrupal7

Page 104: Drupal7 Theming

Render api & hook_page_alterhttp://api.drupal.org/api/function/hook_page_alter/7

• Naar voorbeeld van de FormAPI: meer flexibiliteit en mogelijkheid om zaken te wijzigen in regios en blokken net voor de pagina gerenderd wordt, hele page is 1 array

Page 105: Drupal7 Theming

Render() toepassingen• Voorbeelden

– Regio's en blokken wijzigen met module

• Voorbeeld: een blok dupliceren in een tweede regio• Node links in een sidebar tonen• Banner ad toevoegen aan comment listing

– Volgorde van elementen wijzigen

• Bekijken

– Devel module: show page array

– print_r($page);

Page 106: Drupal7 Theming

function abc_page_alter(&$page) {

Page 107: Drupal7 Theming

hook_page_alter

Page 108: Drupal7 Theming

THEME SWITCHING

Page 109: Drupal7 Theming

Theme switching in settings.php

theme_default: Defines the default theme for this site.

- $conf['theme_default'] = 'garland';

A custom theme can be set for the offline page.- $conf['maintenance_theme'] = 'bartik';

Page 110: Drupal7 Theming

Theme wisselen volgens url

In settings.php

// if the url is an administration page

if (strpos($_GET['q'], 'admin') === 0) {

$conf['theme_default'] = 'garland';

}

Page 111: Drupal7 Theming

Mobile theme

$parts = explode('.', $_SERVER['HTTP_HOST']);

if ($parts[0] == 'mobile') {

$GLOBALS['theme_default'] = 'mobile';

}

Page 112: Drupal7 Theming

IE6 theme

$user_agent = $_SERVER['HTTP_USER_AGENT'];

if($user_agent) {

if ((strpos($user_agent, 'MSIE 6.0')) && (strpos($_GET['q'], 'user') === 0)){

$conf['theme_default'] = 'garland';

}

}

Page 113: Drupal7 Theming

Theme Key module

• Heel flexibele module voor het wisselen theme onder bepaalde voorwaarden

–Tijd: speciaal theme voor bepaalde dagen

–User: ander theme voor user of rol

–Browser: ander theme voor IE6

–Mobile theme, Mobilekey module

• http://kalki.de/en/howto/themekey-tutorials.html

Page 114: Drupal7 Theming

Mobile themes

• App–Titanium/phonegap via html5,css3,js

• Aparte site–Multisite installatie

–Mobile tools module: mobile rol, ...

–Jquery mobile: touch optimized framework

–Detectie: Browscap en wurfl

• Responsive design: flexible images

Page 115: Drupal7 Theming

THEME SETTINGS

Page 116: Drupal7 Theming

Theme settings

• Drupal.org: http://drupal.org/node/177868

• Op admin/appearance/settings/themeName kunnen voor het theme extra settings worden voorzien

• Voordeel: hergebruik in andere themes => gebruiken in base theme

Page 117: Drupal7 Theming

Rebuild Theme Registry

Page 118: Drupal7 Theming

Default settings in .info file

• settings[abc_breadcrumb] = yes

• settings[abc_breadcrumb_separator] = ' › '

• settings[abc_rebuild_registry] = 0

Page 119: Drupal7 Theming

hook_form_system_theme_settings_alter

• Is een hook_FORM_ID_alter implementatie

• Gebruikt in theme-settings.php

Page 120: Drupal7 Theming

theme-settings.php

Page 121: Drupal7 Theming

THEME SECURITY

Page 122: Drupal7 Theming

Theme security

• check_plain()

• check_url()

• check_markup()

• filter_xss_admindrupal_set_title($node->title); // Incorrect

drupal_set_title(check_plain($node->title)); // Correct

Page 123: Drupal7 Theming

Front end Performance

Page 124: Drupal7 Theming

Front-end performance

• Css en js aggregatie

• Image styles, smush.it

• Css sprites

• drupal_add_css en drupal_add_js: selectief css en js toevoegen

• Yslow en Google PageSpeed

• http://wimleers.com/article/improving-drupals-page-loading-performance

Page 125: Drupal7 Theming

Views Theming

Page 126: Drupal7 Theming

Voorbeeld: Views slideshow

• http://drupal.org/project/views_slideshow

• Toepassing: –Fotogalerij

–Dynamic Display block

Page 127: Drupal7 Theming

Views templates

• Basistemplates in de views module folder• Theme Information link in de view zelf geeft suggesties

voor tpl.php files specifiek voor deze view• Theme developer via Devel module: bekijken suggesties

live• Er zijn ook theme_ functies beschikbaar voor views, maar

handiger via tpl.php

Page 128: Drupal7 Theming

Een view beïnvloeden

1) Met de template files views-view.tpl.php (opvragen via de “information link”)

2) Met een hook vb hook_views_admin_links_alter

3) Tijdens het embedden van de view $view->hide_admin_links

Page 129: Drupal7 Theming

Views embedden met module

• http://drupal.org/project/viewfield

• http://drupal.org/project/insert_view

Page 130: Drupal7 Theming

Eenvoudig views embedden

<?php echo views_embed_view('most_recent_post', 'default'); ?>

<?php echo views_embed_view('nieuws', 'block_1'); ?>

<?php print views_embed_view('calendar', 'calendar_block_1'); ?>

Page 131: Drupal7 Theming

Views embedden alternatief

$view = views_get_view($view_name);

$view->set_arguments(array(0 => 'all', 1 => 'typeb')); // if you have args

$view->set_items_per_page(0); // Aantal resultaten

print $view->execute_display(0, $args); // default view, include $args param if using

Page 132: Drupal7 Theming

Geavanceerd embedden via blok

<?php

$view = views_get_view('Publicaties');

//print '<pre>';

//print_r($view);

//print '</pre>';

$view->set_display('block_1');

$view->display_handler->set_option('items_per_page', 2);

$view->set_arguments(args...);

$title = $view->get_title();

$output = $view->preview();

print '<h2>' . $title . '</h2>';

print $output;

?>

Page 133: Drupal7 Theming

FIELDS THEMING

Page 134: Drupal7 Theming

Theming fields

Individuele velden kunnen gethemed worden via field.tpl.php

• field.tpl.php

• field--field-type.tpl.php

• field--field-name.tpl.php

• field--content-type.tpl.php

• field--field-name--content-type.tpl.php

Page 135: Drupal7 Theming

Theme image styles

http://api.drupal.org/api/drupal/modules--image--image.module/function/theme_image_style/7

print theme('image_style', array( 'path' => $field_gallery_image['de'][0]['uri'], 'style_name' => 'gallery_thumbnail'));

Page 136: Drupal7 Theming

Theme image styles

Probleem/bug: width/height van imageshttp://drupal.org/node/908282http://drupal.org/node/1129642

Manueel hoogtes specifierentheme('image_style', array('style_name' => 'desthumb', 'path' =>

$image0path, 'getsize' => TRUE, 'attributes' => array('class' => 'thumb', 'width' => '150', 'height' => '162')));

Tijdelijke workaround:http://api.drupal.org/api/drupal/modules--image--image.module/function/theme_image_style/7#comment-14839

Page 137: Drupal7 Theming

FORMS THEMING

Page 138: Drupal7 Theming

Form theming

Het themen van forms kan via hook_FORM_ID_alter()

Er zijn ook enkele modules die je kunnen helpen een pak zaken zonder code te doen: Display Suite, Panels, Nodeformcolumns

Page 139: Drupal7 Theming

hook_FORM_ID_alter

/** * Implements hook_form_ID_alter(). */function abc_form_comment_form_alter(&$form, &$form_state) { // dpm($form); $form['notify_settings']['notify_type']['#prefix'] = '<div

class="container-inline clearfix">'; $form['notify_settings']['notify_type']['#suffix'] = '</div>';}

Page 140: Drupal7 Theming

hook_FORM_ID_alter

/** * Implements hook_form_ID_alter(). */function abc_form_user_login_block_alter(&$form,

&$form_state) { $form['links']['#prefix'] = '<div class="login-links container-inline

clearfix">'; $form['links']['#suffix'] = '</div>';}

Page 141: Drupal7 Theming

HTML5 en CSS3

Page 142: Drupal7 Theming

Nieuwe mogelijkheden

• Vereenvoudigde html (niet meer xml gebaseerd)

• Nieuwe structuurelementen: <header><footer><section><article><nav><aside>

• Nieuwe formelementen: input type=email, url, date, time, month, week, number, range, search, tel, color. Voordeel: er kan een gebruiksvriendelijke widget worden voorzien

Page 143: Drupal7 Theming
Page 144: Drupal7 Theming

Nieuwe mogelijkheden

• Video: <video>

• Canvas: http://canvaspaint.org

• Data storage: localstorage 5MB en web sql database api

• Offline: cache manifest

• Drag and drop (js)

• Location api (js, niet echt html5)

Page 145: Drupal7 Theming

CSS3

• Voor oudere versies -moz en -webkit nodig. IE soms complexe eigen filter

• transition:background-color .5s;

• transition:z-index .5s, opacity .5s;

• border-radius:3px;

• box-shadow:inset rgba(0,0,0,.75) 0px 0px 10px;

• Text-shadow

• Gradients: http://www.colorzilla.com/gradient-editor/

Page 146: Drupal7 Theming

CSS3 demos

• http://www.css3generator.com/

• http://webdesignerwall.com/trends/css3-examples-and-best-practices

• http://webdesignerwall.com/trends/47-amazing-css3-animation-demos

Page 147: Drupal7 Theming

HTML5 en CSS3 support

• Browser supporthttp://www.findmebyip.com/litmus/

Page 148: Drupal7 Theming

Drupal html5 themes

• Omega

• Adaptivetheme

• Zen v5

Page 149: Drupal7 Theming

GRID SYSTEMS

Page 150: Drupal7 Theming

Grid systemen

Probleemstelling

–Gelijke en eenduidige marges

–Pagina opdeelbaar in 2,3,4,5 kolommen met gelijke marges

Zelf berekenen

–http://gridulator.com/

Page 151: Drupal7 Theming

Grid systemen

http://www.smashingmagazine.com/2008/05/29/applying-divine-proportion-to-web-design/CSS Frameworks•http://en.wikipedia.org/wiki/List_of_CSS_frameworks•http://960.gs: 960px met 12 of 16 kolommen en 20px margin•http://www.blueprintcss.org: 950px met 24 kolommen en 10px margin•YAML: http://www.yaml.de/en

•YUI Grids: http://developer.yahoo.com/yui/grids

Page 152: Drupal7 Theming

Voordelen• Vertrekken van vaste basiscode (wiel niet heruitvinden)• Browser compatibiliteit: Herbruikbaarheid css en hacks voor IE6 (en zelfs IE5,

maar als zelfs msn.com die niet meer respecteert...)• Professionele grid structuur• Flexibele voorgedefinieerde classes voor basiselementen: lijsten, tabellen, forms• Sneller werken, rapid prototyping (ipv wireframing) opstellen van mock-ups• Clean code• Klein <5kb• Iphone viewport is 960px

Page 153: Drupal7 Theming

Nadelen• Jij en iedereen die aan de site werkt moet

het framework kennen• Er is code die je niet gebruikt• Beperkingen in design◦ De xhtml layout zou moeten gebaseerd zijn op het design, niet omgekeerd◦ Fixed width vb 960px, voor 1280px schermen wil je soms 960px + extra niet belangrijke kolom (reclame)

Page 154: Drupal7 Theming

SamenstellingSamenstellingreset.csstypography.cssgrid.cssie.cssprint.cssforms.css

Page 155: Drupal7 Theming
Page 156: Drupal7 Theming

Reset: Tripoli & compressie* {margin:0; padding:0;}: traagEric Meyer:

http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded

Tripoli: http://devkick.com/lab/tripoli/• Compatibel met Windows: IE5, IE5.5, IE6, IE7, IE8, Opera 8, Opera 9, Safari, Firefox 2,

Firefox 3, OS X: IE5, Firefox 2, Firefox 3, Safari 2, Safari 3, Camino

Page 157: Drupal7 Theming

Blueprint• Framework: http://blueprintcss.org • Tools:◦ http://kematzy.com/blueprint-generator

◦ http://code.google.com/p/blueprintcss/wiki/Tools

• Plugins◦ In core: Fancy Type, RTL (right-to-left text and column layout support), Buttons,

Link Icons (bestandstypes, external, ...)

◦ Tabs:http://github.com/Montoya/blueprint-plugin---tabs/tree/master

◦ Liquid: http://github.com/Montoya/blueprint-plugin---liquidgrid/tree/master

◦ Silk icons: http://github.com/Montoya/blueprint-plugin---silksprite/tree/master Voorbeeld: http://nettuts.com/tutorials/html-css-techniques/a-closer-look-at-the-blueprint-css-framework/

Page 158: Drupal7 Theming

960.gs• http://960.gs • Ook fluid: http://www.designinfluences.com/fluid960gs

• En elastichttp://csswizardry.com/typogridphy

• Uitgewerkt voorbeeld:http://nettuts.com/tutorials/html-css-techniques/prototyping-with-the-grid-960-css-framework

Page 159: Drupal7 Theming

Drupal

• Verschillende starter themes gebruiken 960.gs

◦ http://drupal.org/project/ninesixty

◦ http://drupal.org/project/fusion

Page 160: Drupal7 Theming

RESPONSIVE DESIGNCSS3 MEDIA QUERIES

Page 161: Drupal7 Theming

Responsive design

• Layout aanpassen aan schermformaat

• http://www.alistapart.com/articles/responsive-web-design/

• Basisprincipes–Procentueel werken (elastic layout)

–Media queries

–Fluid images

–Aantal kolommen verminderen bij kleinere schermen

Page 162: Drupal7 Theming

Css3: Media queries

<link rel="stylesheet" type="text/css"

media="screen and (max-device-width: 480px) and (resolution: 163dpi)"

href="shetland.css" />

@media screen and (max-width: 600px) {

.footer {

float: none;

width: auto;

}

}

Page 163: Drupal7 Theming

Browser support

• Safari 3+, Chrome, Firefox 3.5+, IE9 en Opera 7+

• Javascript oplossingen– http://plugins.jquery.com/project/MediaQueries

– http://code.google.com/p/css3-mediaqueries-js/

– https://github.com/scottjehl/Respond

Page 164: Drupal7 Theming

Fluid images

• Schaalbare afbeeldingen

• http://www.alistapart.com/articles/fluid-images/

• Verkleinen:http://drupal.org/project/responsive_images

img {

max-width: 100%;

}

Page 165: Drupal7 Theming

Responsive grid layouts

• Grids hebben voor en nadelen bij responsive design

• Adapt.js: http://adapt.960.gs

• Rethinking css grids (toekomstige layouttechnieken): http://www.markboulton.co.uk/journal/comments/rethinking-css-grids

Page 166: Drupal7 Theming

IE en responsive design

• Afbeeldingen: bicubic resize

• respond.js

• http://www.ie6countdown.com En http://www.theie7countdown.com

• Geen IE6 support in core themes van Drupal 8

Page 167: Drupal7 Theming

SPECIALE LETTERTYPES

Page 168: Drupal7 Theming

Speciale lettertypes

• Webfonts: Arial, Verdana, –Css: font-family: Arial, Helvetica, sans-serif;

–Css: font-family: Times New Roman, Times, serif

• Speciale fonts–Zijn niet aanwezig op elke computer

–Fontbedrijven terughoudend omwille van licenties

Page 169: Drupal7 Theming

Webfonts – Websafe fontsVeiligste fonts

• Arial / Helvetica

• Times New Roman / Times

• Courier New / Courier

Ander cross platform

• Verdana

• Georgia

• Comic Sans MS

• Trebuchet MS

• Arial Black

• ImpactPalatino

• Garamond

• Bookman

• Avant Garde

Page 170: Drupal7 Theming

Replacement technieken

• Speciale fonts–Via een image: moet alt tekst hebben voor

toegankelijkheid, niet dynamisch vanuit cms

–Flash

–Javascript

–Css

Page 171: Drupal7 Theming

Flash: Sifr

– Flash: Sifr

• http://www.mikeindustries.com/blog/sifr

• http://www.sifrgenerator.com/wizard.html

• http://drupal.org/project/sifr

– Opmerkingen

• Toegankelijkheid is in orde vermits er in de code gewoon html <h1> etc wordt gebruikt

• Browser moet Flash ondersteunen (iphone/ipad niet)

• Ad-blockers kunnen de weergave blokkeren

• Traag: behoorlijk wat Flash, css en js code te genereren, enkel voor titels, niet voor volle tekst

• Letters niet heel zuivere randen

Page 172: Drupal7 Theming

Javascript: Cufon

• Via javascript: Cufon

– http://cufon.shoqolate.com/generate

– http://drupal.org/project/cufon

• Opmerkingen

– Heel goed opletten met welke lettertekens je toelaat, teveel is nadelig voor performantie, te weinig laat letters met accenten niet verschijnen

– Internet Explorer is traag in javascript dus traag in Cufon

– Hoe meer lettertypes je gebruikt hoe meer javascript moet geladen worden per pagina

– Lettertypes niet heel zuivere randen

Page 173: Drupal7 Theming

Css @font-face

• Geïntroduceerd in 1998, pas ondersteund door alle browsers in 2010 wegens licentieproblemen.

• Gratis fonts

– http://www.google.com/webfonts

– http://www.fontsquirrel.com

– http://www.theleagueofmoveabletype.com/

• Formaten:

– Ttf: True Type, standaard desktop formaat

– Woff: Web Open Font Format, zou moeten de standaard worden

– Eot: Embedded Open Type, ttf verpakt in DRM, enkele Microsoft

– Svg: Scalable Vector Graphics, oudere iphones

Page 174: Drupal7 Theming

Css: gebruik

Internet Explorer

@font-face {

font-family: MyKievit;

src: url(/fonts/KievitWebPro-Medium.eot);

{

Firefox

@font-face {

font-family: MyKievit;

src: url(/fonts/KievitWebPro-Medium.woff) format('woff');

{

body { font-family: MyKievit, Arial, sans-serif; }

Page 175: Drupal7 Theming

Browser support

Formaat Firefox 3.6+

Chrome 6+

IE 6-8 IE9 Safari 3.1+

IOS Android 2.2

EOT x xTTF x x x X (>4.2) xSVG x X (<4.2)

WOFF x x x

• Bron: http://www.webfonts.info/wiki/index.php?title=@font-face_browser_support

Page 176: Drupal7 Theming

@font-face kits

• Bevat

– Eot, woff, ttf, svg

• Waar?

– Gratis

• www.fontsquirrel.com/fontface

• www.fontsquirrel.com/fontface/generator

– Betalend:

• http://www.fontspring.com/fontface: als kit

• www.typekit.com, www.fonts.com, www.fontslive.com, www.fontdeck.com, www.web-type.com: als abonnement, hosted service, licencing ok, eenvoudig codesnippet compatibel met alle browsers, goedkoper want enkel webdeel van font gekocht, betalen per pageviews of per font.

Page 177: Drupal7 Theming

@font-face in de praktijk

@font-face {

font-family: 'MyFontFamily';

src: url('myfont-webfont.eot?') format('eot'),

url('myfont-webfont.woff') format('woff'),

url('myfont-webfont.ttf') format('truetype'),

url('myfont-webfont.svg#svgFontName') format('svg');

}

Browser support: Safari 5.03, IE 6-9, Firefox 3.6-4, Chrome 8, iOS 3.2-4.2, Android 2.2-2.3, Opera 11

Bron: http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax

Page 178: Drupal7 Theming

NIEUWSBRIEF THEMING

Page 179: Drupal7 Theming

Nieuwsbrieven

• 3 voornaamste mogelijkheden

–Simplenews: eenvoudig en goedkoop, geen bounce handling, beperkte statistieken, problemen met server gemarkeerd als spamserver

–Campaignmonitor of Mailchimp integratie: full bounce handling, statistieken, whitelisting, betalend maar Mailchimp tot 1000 abonnees gratis!

–Civimail (onderdeel van Civicrm): mailings, bounce handling, goed systeem

Page 180: Drupal7 Theming

Nieuwsbrief theming

● http://www.campaignmonitor.com/css/● http://drupal.org/node/268404 ● Probleem: css moet inline voor webclients (gmail,

yahoo, hotmail)

–Views templates maken voor onderdelen

–Automatisch: Emogrifier (htmlmail), Mime Mail CSS Compressor (mimemail)

–Display suite

Page 181: Drupal7 Theming

Nieuwsbrief theme

Via Themekey module: als ct nieuwsbrief of view nieuwsbrief => Nieuwsbrief theme gebruiken

• Nieuwsbrief theme–Geen html5 en andere moderne zaken, terug naar

de nineties!

–Sterk vereenvoudigde html.tpl.php: geen css en js printen

–Sterk vereenvoudigde page.tpl.php: enkel tabel

Page 182: Drupal7 Theming

Nieuwsbrief theme

• Views: <?php print views_embed_view('nieuwsbrief_items','default'); ?>

• Reference field: <?php print render($content['field_nb_architectuurnieuws']); ?>

• Veld: <?php print check_url($node->field_nb_subfoto1_linkt['und'][0]['url']); ?>

Page 183: Drupal7 Theming

Aanpak 2: via views

• Nodequeue: Toevoegen aan nieuwsbrief

• View: Nieuwsbrief op /nieuwsbrief

• Nieuwsbrief = page - - nieuwsbrief.tpl.php–Views_embed_view('eersteview');

–views_embed_view('tweedeview');

• Nadeel: geen inleiding, archief via Mailchimp

Page 184: Drupal7 Theming

Aanpak: Eigen inhoudstype

• CT Nieuwsbrief–Met velden voor foto's, tekst, links

–Reference fields voor lijsten

Page 185: Drupal7 Theming

Simplenews theming

● simplenews-newsletter-body--1126.tpl.php

● simplenews-newsletter-footer--1126.tpl.php

Page 186: Drupal7 Theming

THEMING VANUIT DE DRUPAL INTERFACE

Page 187: Drupal7 Theming

Theming Alternatieven: Modules

• Context: www.drupal.org/project/context

• Panels: www.drupal.org/project/panels

• Display Suite: www.drupal.org/project/ds

• Sweaver: www.drupal.org/project/sweaver

Page 188: Drupal7 Theming

PANELS

Page 189: Drupal7 Theming

Panels: doel en historiek

• Panels = layoutbuilder in Drupal

• Earl Miles (Views)

• Sony www.myplay.com

• Versies 1,2,3

• Toekomst: Drupal 8 misschien een eenvoudige panels achtige interface voor toevoegen van content in Drupal core

• Documentatie: http://drupal.org/node/496278

Page 190: Drupal7 Theming

Panels: voordelen

– Point en click Drupal theming zonder html en php, templates opstellen via de interface

– Slechts 1 soort inhoudsobject: panel waarin blokken, menus, views, velden, ... kunnen weergegeven worden => alles eenvormig op dezelfde manier behandelen

– Complexe pagina layouts mogelijk zonder voorkennis van html/css

– Flexibeler layouts: vb zelfde blok in verschillende regios, ...

– Makkelijker en sneller wijzigingen aanbrengen aan templates

– Ctools: vastleggen van layouts in exportables en features => exporteerbaar dus hergebruikbaar en opgenomen in svn/git revisiesysteem.

– Varianten: andere soorten layouts volgens context, vb ingelogde klanten/leden, mobiele website

– Integreert heel goed met views

Page 191: Drupal7 Theming

Panels: nadelen

• Performance: is heel grote module, wel goede caching opties

• Kan complex zijn: is systeem op zich met leercurve en heel veel checkboxen

• Werkt behoorlijk anders dan “the Drupal way” => bloksysteem en regios uitschakelen (vinkje)

• Alles of niets: als je panels gebruikt het voor alles gebruiken

• Moeilijker te debuggen

• Soms trage upgrade bij nieuwe versie van drhttp://www.youtube.com/watch?v=qBGKdnUj4Ywupal core , en upgrades tussen v1, 2 en 3 waren niet vanzelfsprekend, maar ondertussen heel veel gebruikt (> 80.000 installs)

• Overladen html tenzij je eigen custom templates opstelt

Page 192: Drupal7 Theming

Submodules en extra

• Page Manager (bij ctools): page layouts (beetje zoals page.tpl.php)

• Mini panels: blok layouts

• Panel nodes: node layouts

• Views content panes: views in panels

• Panels Everywhere

Page 193: Drupal7 Theming

Layouts

• Standaardlayouts

• Bepaalde themes definiëren extra layouts zoals Adaptive Theme (AT) in d6

• http://drupal.org/project/panels_extra_layouts: extra layouts:

• Best: eigen html templates voor layout

– Advanced help module: help/panels/plugins-layout

– tpl.php, css, inc en png

– Meer docs: http://drupal.org/node/495654

Page 194: Drupal7 Theming

Variants

• Andere layout voor zelfde pagina bij andere voorwaarden

– Volgens content type: basic page er anders laten uitzien dan artikels

– Volgens toegangsrol: admin, ingelogden, leden/klanten zien iets anders

– Volgens taal

– Volgens trefwoord, ...

– Mobile themes dank zij integratie met de http://drupal.org/project/mobile_tools module

Page 195: Drupal7 Theming

Contexts

• Arguments–/taxonomy/term/%term

–/forum/%forum

–/music/beatles/th

• Andere contexts–Node auteur

–Node reference

Page 196: Drupal7 Theming

MOCKUPS

Page 197: Drupal7 Theming

Mockups

Moderne software voor Mockups

–Mockflow: http://www.mockflow.com

–Mockingbird: https://gomockingbird.com

–Balsamiq: http://balsamiq.com

Page 198: Drupal7 Theming

DISPLAY SUITE

Page 199: Drupal7 Theming

Filosofie achter Display Suite

• Centraal beheer van layout van website inhoud• Template bestanden overbodig maken

• Focus op gebruiksvriendelijkheid• Gebruik van PHP beperken = betere veiligheid

Page 200: Drupal7 Theming

Layout beheer met Drupal core

• Mix van template bestanden en Field UI

• Nadelen:–Template bestanden zijn niet onderhoudbaar

–Field UI is beperkt: • Geen UI om extra velden toe te voegen (vb. titel,

auteur)

• Geen UI om extra View Modes toe te voegen

• Inconsistent: 'Search result' View Mode

• Geen gebruik van voorgedefinieerde layouts

Page 201: Drupal7 Theming

Layout beheer met DS

• Bouwt verder op Field UI

– Nieuwe View Modes aanmaken

– Voorgedefinieerde layouts aanmaken

– Eigen velden toevoegen

• Integratie met Views en Panels

• Werkt op elke Drupal Entity (Node, gebruiker etc)

• Consistente HTML output

• Oefening 1: DS aanzetten en Node en Teaser layout wijzigen

Page 202: Drupal7 Theming

DS layouts• Standaard: 11 layouts + Panel layouts

• Eigen layout in theme:–ds_layouts folder aanmaken

– ***.inc en ***.tpl.php bestanden verplicht

– ***.css optioneel

–Voorbeeld: ds.api.php lijn 356.

–Oefening 2: Eigen layout met 3 rijen in theme toevoegen

Page 203: Drupal7 Theming

Correct Css'en met DS• Beschikbare classes: Entity, eventueel Content Type, View mode en Groups. Voorbeeld:

<div class="node node-article view-mode-teaser"> <div class="group-header"> <h2>Lorem ipsum</h2> </div> <div class="group-middle"> <p>Lorem ipsum.</p> </div></div>

• Zo generiek mogelijk, indien nodig specifieker:

.view-mode-teaser .group-header {}.node.view-mode-teaser .group-header {}.node-article.view-mode-teaser .group-header {}

• Werk zoveel mogelijk op DS classes ipv HTML van andere modules

• Oefening 3: css schrijven voor ?

Page 204: Drupal7 Theming

Extras module

• Field templates• Contextual links

• Regions to block

• Page title options

• Views Displays

• En veel meer!

Page 205: Drupal7 Theming

Andere toepassingen

• Zoekresultaten

• Views slide show met meerdere content types

• Oefening 4: slideshow opzetten: custom View mode en voor alle content types instellen.