DRUPAL DEV Training Introductie
Lucius WebsystemsRobbenkoog 29a1822 BA Alkmaar072-564 90 [email protected]
About
Drupal
Introductie Drupal
Geschiedenis
Huidige stats
Drupal association & DrupalCons
Drupal
Wanneer Drupal?
Bedrijfswebsites
Online communities
Intranets
Enterprise oplossingen
Webwinkel
Weblog
Multi site platforms
And many more..
Drupal
Enkele Drupal Features
Multi talig
Version control
Commentaarsysteem
Download systeem
Logs en error-reporting
Forum
Blog (+API)
Poll
Drupal
Zoekmachine
Aggregator
RSS
Gebruikersrechten – beheer (ACL)
Multi – site
Taxonomy
Waarom Drupal?
Stabiele foundation en gepassioneerde community
Snel en veilig
Krachtig en schaalbaar
Innoverend
Zeer zoekmachinevriendelijk
Krachtig en Flexibel templating systeem
Award winning
Many more..
Drupal
Waarom Drupal? part 2
Modulair systeem
Hooks
Content types
Taxonomy
Drupal API
Theming & overriding
NBS (Node Based System)
Vele modules werken met elkaar samen Synergie
Backend en frontend theming
Drupal
Waarom Drupal? part 3
Content management op maat
Content invoer (oa CCK)
Content output (oa Views)
Drupal
Benodigde kennis
PHP 5
MySQL
SQL
(X)HTML / CSS & Webstandaarden (W3c)
FTP
Localhost voor ontwikkeling
Drupal
Aftasting kennis in huis
Drupal
Wie heeft wat al gedaan?
Belangrijke Drupal modules: Administration Menu CCK Views Image / assist / api Pathauto Global redirect Token Webform Poormanscron FCK Editor Devel
Belangrijke Drupal terminologie
Module
Nodes
Users
Blocks
Pages
Taxonomy
Content typen & Content (cck) fields
Sessions
Drupal
Hooks
Theme
Cron
Cache
Input format
Watchdog
API
i18n
Drupal File Layout
Drupal
Bron afbeelding: http://www.ddj.com/linux-open-source/199201603?pgno=5
Introductie Drupal modules
Hoe om te gaan met open source modules
Goed kijken hoe ‘contrib’ modules gemaakt zijn. Soms beter dan core modules, omdat die al lang in dev zijn.
Gebruik de enorm actieve community correcte wijze
Vele modules werken met elkaar samen
Drupal werkt veel met titles, naamgeving is belangrijk
Dagelijks checken: Latest Drupal modules
http://drupal.org/project/modules?solrsort=ds_project_latest_release%20desc
http://www.drupal.org/planet
Drupal
Online Developer resources
Module developer's guide http://drupal.org/contributors-guide
Drupal beyond the basics: http://drupal.org/handbook/customization
Drupal coding standards: http://drupal.org/coding-standards
Writing secure code: http://drupal.org/writing-secure-code
Best practices: http://drupal.org/node/287350
Working with Drupal API http://drupal.org/node/326
Use of underscore in Drupal functions http://drupal.org/node/70335
Guidelines for writing efficient SQL code http://drupal.org/node/559302
Creating new content type http://drupal.org/node/231019
Using Theme layer http://drupal.org/node/165706
Drupal
Online Developer tools
Drupal for firebug http://drupal.org/project/drupalforfirebug
Devel module: http://drupal.org/project/devel
Cache disable http://drupal.org/project/cache_disable
Use to check you coding on: http://drupal.org/project/coder
Use to extensivly check your code on: http://drupal.org/project/coder_tough_love
Trace http://ar.to/2006/12/easier-drupal-debugging-with-trace
Looking for a module: http://www.drupalmodules.comLooking for a module: http://www.drupalmodules.com
Drupal
Developer boeken
Pro Drupal development – John vanDyk & Matt Westgate
Learning Drupal 6 module development – Matt Butcher
Leveraging Drupal – Victor Kane
Cracking Drupal – Greg James Knaddison
Drupal
Coding standards & best practices
Coding standards: http://drupal.org/coding-standards
Writing secure code: http://drupal.org/writing-secure-code
Best practices: http://drupal.org/node/287350
Voorbeeld: $string = "Foo $bar"; (PHP)
Online resources: Standards, security and best practices http://drupal.org/node/360052 Readme.txt van module coder tough love
Drupal
Drupal API
De Drupal API http://api.drupal.org
Enkele API functies l(); url(); node_load(); node_view() arg(); t(); drupal_get_path(); check_plain(); variable_set, variable_get() & variable_del() database abstraction layer
Drupal
Database
API reference http://api.drupal.org/api/group/database/6
Secure code: http://drupal.org/writing-secure-code
Schema API: http://drupal.org/node/146843 Updaten Schema van een module : check system table
Drupal
Creating modules
Creating modules tutorial: http://drupal.org/node/206753
API reference http://api.drupal.org
Hooks http://api.drupal.org/api/group/hooks/6
PHP Library: http://w3schools.com/php/
SQL Library: http://w3schools.com/sql/
Creating modules tutorial: http://drupal.org/node/206753
Drupal
Module architectuur
Benodigde bestanden: .info definiering module info en dependencies .module de code
Optioneel LICENSE.txt wordt automatisch door drupal toegevoegd README.txt handmatig toevoegen .inc voornamelijk voor modules met veel code .install Help Translation files in aparte folder Theming files (tpl.php) UPGRADE.txt
Drupal
Module architectuur
Naamgeving is zeer belangrijk in module
Zorg voor unieke id in benaming van module, de naam werkt door in: Module map en definiering Functies in de module Dbase tables system variables url css classes Hooks Theming files
Drupal doorloopt de modules in alfabetische volgorde.
Het is mogelijk een weight aan een module toe te kennen.
Drupal
Hooks
Uitleg: Wat is een Hook en wat kan je ermee
Alle acties binnen cms waar je een hook kunt verwachten, daar zit er een.
Hooks http://api.drupal.org/api/group/hooks/6
Cheatsheet http://drupal.org/files/drupal_6_core_hooks_cheat_sheet.pdf
Demo gebruik van enkele Hooks
Drupal
Code validatie
Demo code validatie in Drupal
Drupal
Content filtering
Demo input formats
Drupal
Productie filter module
Opdracht 1: produceer een filter module
Definieer module / benodigde files
Drupal
Drupal
Productie filter module, tip toevoegen
Opdracht 2: produceer de filter tip Zoek correct hook op
Schrijf de code
Productie filter module
Opdracht 3: produceer een filter, die ingevoerde tekst analyseert en bij output een woord hierin wijzigd.
Drupal
Productie filter module
Opdracht 4: produceer admin gedeelte je te wijzigen woord kan instellen
Drupal
Productie filter module
De code toegelicht
Code validatie
Drupal
i18n opdracht
Demo i18n
Oefening i18n
Taxonomy Vocabularies & terms
Content types & taxonomy
Taxonomy API functions
Taxonomy output in theme, voorbeeld
Kan gebruikt worden door modules (bv forum)
Check hoe Drupal bv taxonomy_node_get_terms() gebruikt op api.drupal.org
Menu system
hook_menu()
Menu item & wildcard voor variabele
Title
Page callback
Page arguments
Access arguments
Type
MENU_NORMAL_ITEM (default, maakt menu item aan)
MENU_CALLBACK
Hook menu
MENU_LOCAL_TASK (gebruik werkwoord)
MENU_DEFAULT_LOCAL_TASK (gebruik werkwoord)
Weight
File
Hooken in bestaande menu items hook_menu_alter()
Menu tabs
Verbergen van menu items
Enkele API Functies pager_query
drupal_set_message()
watchdog()
cache_clear_all()
user_access()
format_date()
drupal_set_header()
node_access()
pager_query
menu_tree_all_data
drupal_goto
function image_get_info
user_is_logged_in
Drupal files systeem Demo file handling in Drupal
Form API Form API reference
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html
Form API: http://drupal.org/node/37775
Form API upload field :http://drupal.org/node/111782 & http://www.imedstudios.com/labs/node/22
Form API Elements reference http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6
Form functions http://api.drupal.org/api/group/form_api/6
Enkele ‘Form controls’ Texfield
Submit
Checkboxes
Select
Hidden
Radios
Weight
Fieldset
Markup
Button
Date
Password
Item
Enkele ‘Form Attributes’ #theme
#tree
#access
#title
#default_value
#maxlenght
#required
#weight
#description
#prefix & #suffix
#ahah
#attributes
Form API functies Uitleg van enkele belangrijke form functies:
http://api.drupal.org/api/group/form_api/6
Form API, Validate Validate functies stanaard
Validatie functies toevoegen aan een bestaand form
Form API, Submit Submit functies standaard
Submit functies toevoegen aan een bestaand form
Productie ‘lingo’ module Nieuwe module aanmaken
Menu hook
Alleen definiering velden mbv FAPI
Productie ‘lingo’ module Extra veld definieren
Veld verplicht maken (*)
Productie ‘lingo’ module Vergelijken tekstvelden
Foutmelding wanneer niet gelijk
Wanneer ‘te raden woord’ leeg: foutmelding uit core
Wanneer ‘gok’ leeg is: custom foutmelding verschijnt
Productie ‘lingo’ module Voorbeeld functionaliteit
Productie ‘lingo’ module Voorbeeld functionaliteit
Productie ‘lingo’ module Productie 2e menu hook
Validatie veld: altijd 6 karakters, kleine letter, geen cijfers
Opslaan veld in dbase
Productie ‘lingo’ module Melding geven wanneer nieuwe invoer voor oplossing gevalideerd is
Productie ‘lingo’ module Antwoord verborgen inladen
Vergelijken van invoer met antwoord
1e letter weergeven van antwoord
Productie ‘lingo’ module Foutmelding bij verkeerde gok
Log toevoegen: welke waarden zijn al gegokt.
Waarden schrijven naar ‘watchdog’ (log)
Productie ‘lingo’ module Je hebt max 6 pogingen, daarna verschijnt antwoord
Log op beeld leeg na 6 pogingen
Counter resetten, zodat je opnieuw kan proberen
Productie ‘lingo’ module Oplossing is goed
Log in beeld leegmaken
Goedmelding geven
Productie ‘lingo’ module Permissies toevoegen
Diverse demo’s Demo multiple-page
Demo multi button
Demo Captcha implementatie
Database Schema API Demo gebruik Database Schema API
.install file
Oefening gebruik Database Schame API
Drupal Theming System
Theming system
xHTML / CSS
Javascript & jQuery
Custom vs voorgecodeerd
Veel themes beschikbaar
Garland als voorbeeld theme
Garland als backend theme
Online resources
Anatomy of Drupal 6 theme http://drupal.org/node/171194
Drupal 6 theming documentation http://drupal.org/theme-guide/6
Core tpl-files and vars (cheat sheet) http://drupal.org/node/190815
Drupal coding documentation: http://drupal.org/node/360052
Secure code http://drupal.org/writing-secure-code
Use the Theme developer module http://drupal.org/project/devel
HTML en CSS tools en techniques http://drupal.org/node/37156
Theming forum http://drupal.org/forum/3
Theming layer in modules http://drupal.org/node/165706
Theme anatomy
Bron afbeelding:http://drupal.org/node/171194
Enkele Theme Files
In Folder: sites/all/themes/[theme_naam]
.info
page.tpl.php
node.tpl.php
block.tpl.php
template.php
page-front.tpl.php
Images folder
Css folder
Screenshot.png
Comment.tpl.php
Favicon
Enkele Theme Files .info
variabelen: http://drupal.org/node/171205 deafults: http://drupal.org/node/171206theme_get_registry()
page.tpl.phphttp://api.drupal.org/api/file/modules/system/page.tpl.php/6
node.tpl.phphttp://api.drupal.org/api/file/modules/node/node.tpl.php/6
Features en color Toevoegen features http://drupal.org/project/themesettingsapi
Color module http://drupal.org/node/108459
Regions Assignen van blocks/content aan regions
http://drupal.org/node/171224
Demo inrichten regions
Theme variables $styles
$scripts
$head
$content
$closure
$base_path
$language
print $regionname
$directory
$tabs
$tabs2
$title
$breadcrumb
$show_messages /$messages
$help
$front_page
$is_front
Core templates (cheat sheet) http://drupal.org/node/190815
Enkele API functies voor theming
format_date()
l()
url()
t()
Sanitizing functions
check_plain()
check_markup()
filter_access()
filter_xss_admin()
drupal_add_css()
API functions in theme Demo API functions in theme aanroepen
Theme overriding “Overriding”, dus geen “overwriting”
pages
blocks
tpl.php files in modules
Overriden van tpl files mbv theme functies
Standaard Drupal functions:
theme('item_list')
theme(’table’)
Overriding voorbeeld pages
Page-[front|internal/path].tpl.php
blocks
Block-modulename-delta.tpl.php
Block-modulename.tpl.php
Block-region.tpl.php
Block.tpl.php
Theme hooks & overriding Functions in modules (theme_%)
http://api.drupal.org/api/group/themeable/6
Overriden van tpl files mbv theme functies
Sinds D6: registreren theme hooks
Theme registry & cache
Custom variables in theme http://drupal.org/node/223430
Extra variabelen toevoegen in preprocessing
<?php function template_preprocess_foo(&$variables) { $variables['foo_list'] = array( 'list item 1', 'list item 2', 'list item 3', );} ?>
Wijzigen/ toevoegen data aan bestaande variabelen.
Theming tools Devel module
Validatie html & css. http://validator.w3.org
Firefox:
Drupal for firebug. http://drupal.org/project/drupalforfirebug
Web developer toolbar
Firebug
Yslow
Total validator
Oefening Registreer theme
Screenshot toevoegen
Theme activeren in Front-end
Oefening Implementeer statische html
mbv theme files en variables
Oefening Regio’s definieren
Oefening Themen page, variabelen inladen
Oefening Menu items themen
Block themen
List page themen mbv:
Views
CCK
Imagefield (+dependecies)
Imagecache
Image api
+ dependencies
Oefening
List page themen mbv menu hook in custom module
Submenu afhankelijk van hoofdmenu tonen
Submenu active state themen
Oefening, CCK themen Extra content type definieren
Met CCK velden definieren
Output voor die velden themen
De custom ‘CCK’ velden:
Image mbv: Imagecache
Introtekst
Divers Demo Multi site theming
Demo LTR / RTL (Left To Right / Right To Left)
Demo Subtheming
Oefening Oefening Multi site theming
Oefening LTR / RTL (Left To Right / Right To Left)
Oefening Subtheming
Afsluiting, wrap it up
Top Related