Vancouver League of Drupallers - Remembering the User (August 2008)
-
Upload
baronmunchowsen -
Category
Business
-
view
1.427 -
download
0
description
Transcript of Vancouver League of Drupallers - Remembering the User (August 2008)
1
Remembering the User
A few simple things you can do to enhance the Drupal experience for your
users
2
Introduction
» Hello my name is Oliver Walker» Using Drupal for a year or two» Develop websites for small businesses
» http://www.ventureweb.net
» Front end developer/themer» Themeing» Build Small ‘helper’ modules
3
Who am I enhancing it for?
» My ‘user group’ might not be your ‘user group’» Lots of different types of drupal users
» Module Developers» Site Administrators» Content Writers» People who leave comments» People who just look at your website» …and more…
4
So who then?
» 1 - 3 people who ‘administer’» And by administer I mean…
» Change content anywhere from daily to weekly» Add/edit content» Moderate comments» Moderate revisions » Basic user administration
» Business areas» (Local) Government» Tourism Industry» Small Business
5
4 things…
…I have done to improve the experience of drupal for the users
defined previously.
6
#1) Menu Settings
» Ordering Pages with the Menu System:» Default» Intuitive
» Drawbacks:» Menu Settings on content authoring form has all the links
in there» Have to grant ‘administer menus’ permissions
7
#1) How to:
» If you don’t want to write your own module!..» Go: Admin > Site Building > Menus > Settings
» Drupal 6» “Default Menu for content”
» Drupal 5:» “Content authoring form settings”
» However» Drupal 5 restricts access totally» Drupal 6 defines initial ‘starting point’
8
#1) Links and Resources
» Some resources» http://drupal.org/node/270273
9
#2) User Profile Page
» Consider the sites and the users » No social media (buddy lists, alerts, favorites etc.)» What does the user page have on it?
» “Member for x days…”
» Can it be more usable?
» Blocks, custom layouts to add useful content e.g.» Links to create content
» (copy node_add() from node.module)
» Lists of user’s content» Comments requiring administration» Revisions that need approval
10
#2) User Profile Page - D5 code:
/*** USER PAGE ***/function _phptemplate_variables($hook, $vars) { $vars = array(); if ($hook == 'page') {
global $user;if (arg(0) == 'user' && arg(1) == $user->name){
$suggestions[] = ’page-user';$vars['template_files'] = $suggestions;
} } return $vars;}
/*** USER PAGE CONTENT ***/function phptemplate_user_profile($user, $fields = array()) { return _phptemplate_callback('user-profile, array('user' => $user, 'fields' => $fields));}
Add to your template.php file
11
#2) User Profile Page - D6
» Just create the template files» user-profile.tpl.php» page-user.tpl.php
» …and remember to clear the cache!» Admin > Site configuration > Performance
» http://ww.example.com/admin/settings/performance
» or use Devel Module
12
#2) User Profile Page
» You can then theme the new template files as you would any other template file:» user-profile.tpl.php» page-user.tpl.php
13
#2) Links and Resources
» “Add Blocks to your User Profile page in Drupal 5 and 6”» http://stevekrueger.com/
» http://drupal.org/node/35728
14
#3) Content authoring forms
» Sometimes Content authoring form can get long.
» Theme the form so that, for example, it:» Looks more like the node itself» Provides further instruction to the user» Looks like an administrative theme
15
#3) Content Authoring forms
» You can go a long way with just css.» Creating specific template files gives you full
control» Better use of space» Add extra help text, links for user assistance etc.» Whatever you can think of
16
#3) Content Authoring forms - D5
/*** ADD NEW ***/if ((arg(0) == 'node') && (arg(1) == 'add')){ if(arg(2) == ’yourNodeType'){ function phptemplate_node_form($form) { return _phptemplate_callback('node-yourNodeType-edit', array('user' => $user, 'form' =>
$form)); } }}
/*** EDIT EXISTING ***/if ((arg(0) == 'node') && (arg(2) == 'edit')){ $node = node_load(array('nid' => arg(1))); if($node->type == 'yourNodeType'){ function phptemplate_node_form($form) { return _phptemplate_callback('node-yourNodeType-edit', array('user' => $user, 'form' =>
$form)); } }}
Add to your template.php file
17
#3) Content Authoring Forms - D6
function yourThemeName_theme(){ return array( ’yourNodeType_node_form' => array( 'arguments' => array('form' => NULL), 'template' => 'node-yourNodeType-edit', ), );}
…and remember to clear the cache!
Add to your template.php file
18
node-yourNodeType-edit.tpl.php
» drupal_render($form[‘title’])» Will render the form title
» drupal_render($form[‘field_xxxxx’])» Will render field_xxxxx
» drupal_render($form)» Will render the form» Will render what is remaining of the form after other fields have
been rendered
» How do I find out what form values there are for me to render?» print ‘<pre>’;» print_r($form);» print ‘</pre>’;
19
#3) You can also alter default form values
» For example» Number of rows in a textarea» Size of a specific text field» Making things collapsible or not» Value of a button (submit, edit, delete)» Remove a form component altogether.
20
#3) Drupal 5 - form value overrride
/*** add*/if ((arg(0) == 'node') && (arg(1) == 'add')){
if(arg(2) == 'listing'){ function phptemplate_node_form($form) {
$form['body_filter']['body']['#rows'] = 30; $form['field_sq_foot'][0]['value']['#size'] = 5; $form['preview']['#value'] = “Preview the listing”; $form['submit']['#value'] = Create!"; unset($form['menu']);
return _phptemplate_callback('node-listing-edit', array('user' => $user, 'form' => $form));
…
Add to your template.php file
21
#3) Drupal 6 - form value override
function vwtheme_preprocess_listing_node_form(&$vars) {
$vars['form']['buttons']['submit']['#value'] = "Cowabunga"; $vars['form'][ 'field_sq_foot'][0]['value']['#size'] = 5;
……
}
Add to your template.php file
…and remember to clear the cache!
22
#3) Links and Resources
» http://www.drupal.org/101092» Lullabot tutorial (modifying forms in general)
» Covers how to alter using a module and hook_form_alter» http://www.lullabot.com/articles/modifying-forms-5-and-6
» Template suggestions» http://drupal.org/node/223440
23
#4) Video Content as bonus to README
» Readme files are important » Who doesn’t like to watch video!» Tailored video makes people feel warm and
special» Easy to make» Screen capture software
» e.g. iShowU @ shineywhitebox.com for $20 US
» Product Placement as a possible revenue stream??