Vancouver League of Drupallers - Remembering the User (August 2008)

23
1 Remembering the User A few simple things you can do to enhance the Drupal experience for your users

description

Slides from a presentation I gave at the August 2008 meeting of the Vancouver Group of Drupallers (http://groups.drupal.org/vancouver) which covers 4 simple ways to enhance drupal for users of your drupal websites. N.B. I have removed screenshots and video unfortunately, but the code and links are there.

Transcript of Vancouver League of Drupallers - Remembering the User (August 2008)

Page 1: 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

Page 2: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 3: Vancouver League of Drupallers - Remembering the User (August 2008)

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…

Page 4: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 5: Vancouver League of Drupallers - Remembering the User (August 2008)

5

4 things…

…I have done to improve the experience of drupal for the users

defined previously.

Page 6: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 7: Vancouver League of Drupallers - Remembering the User (August 2008)

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’

Page 8: Vancouver League of Drupallers - Remembering the User (August 2008)

8

#1) Links and Resources

» Some resources» http://drupal.org/node/270273

Page 9: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 10: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 11: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 12: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 13: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 14: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 15: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 16: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 17: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 18: Vancouver League of Drupallers - Remembering the User (August 2008)

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>’;

Page 19: Vancouver League of Drupallers - Remembering the User (August 2008)

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.

Page 20: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 21: Vancouver League of Drupallers - Remembering the User (August 2008)

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!

Page 22: Vancouver League of Drupallers - Remembering the User (August 2008)

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

Page 23: Vancouver League of Drupallers - Remembering the User (August 2008)

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??