dn d custom 1

25

Upload: ptalindstrom

Post on 18-May-2015

452 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Dn D Custom 1
Page 2: Dn D Custom 1

Setup, Intro

Views Basics Argument Handling

Tabbed Views Templating Fusion / Union

A Break From Views Actions Workflow Workflow_NG CCK Computed Field (time

permitting)

Development Tips phpED demo Multisite for Multi-User

More Views (time permitting) Views_build_view() Views and AJAX Views_Calc

Morning : 8 to 12 Afternoon : 1 to 5

BREAKBREAK

LUNCH

Page 3: Dn D Custom 1

What is VIEWS? http://av1.example1/admin/build/views/add

A smart SQL query builder (plus extras) By default – “a view is a list of ALL site nodes”… but… … this is more useful when we FILTER to show only

specific nodes Arguments and filters can be set to limit which nodes

to “list” Can also:

select which fields to use sort theme

Page 4: Dn D Custom 1

Keep in mind – views lists nodes. (Exercise 1, 1a)

Drupal saying: “everything’s a node”… but, of course, not really everything…

Lots of things in Drupal aren’t natively nodes” Users Taxonomy terms Comments And others

But there are modules to make most of these things into nodes… so then they can be used with views..

Page 5: Dn D Custom 1

Page or Block Very similar except Block Views automatically show in

the Block admin page so block functions apply (page filters, per theme, weightings, etc)

View Type List (ALWAYS use this to theme) Table – nice if you want to throw together a quick table Teaser – very handy if you theme a teaser

(contemplate) and have many views that use same teaser template

Other modules can add other types (RSS, etc)

Page 6: Dn D Custom 1

Fields – Table and List only Pick which fields to show on your view

Filters and Arguments Pick which nodes to show

Arguments: use $_GET (i.e. URL) to pass arguments to use

for filtering (more on this later)

Exposed Filters Let users chose filtering options (Exercise 2)

Sort

Page 7: Dn D Custom 1

Arguments are basically filters But we can take arguments from URL to use in our

filters (Exercise 3)

Why take instead of pass? Block views can also read from URL

Argument handling code (PHP) allows us to convert argument into what the filter is designed to handle Think of: better to have URL with text but need ID for filter.

But also other uses: Embed into the views array (http://av1.eclipse/archived)

Handle end cases – i.e. filter bad arguments (http://av1.training/user/blah/my_widgets) (Exercise 6)

Page 8: Dn D Custom 1

Used to collect multiple views together on single

page (Exercise 4)

Views automatically builds tabbed pages for you

based on path provided

Can also add to existing pages such as User, or

other existing tabs created by 3rd party modules (Exercise 5)

Page 9: Dn D Custom 1

Easiest approach is to theme a node type’s teaser and then just use teaser views…

… but when that’s not enough… Views provides very powerful templating support. Basic approach (Exercise 7)

List view (only LIST views work for templating) Select required fields Use views Theme Wizard to get code for template.php,

views-list-[view_name].tpl.php, views-list-[view_name].css

Page 10: Dn D Custom 1

All tpl files belong in the theme folder

LiquidCMS Enhancements:

Support for multiple themes by better use of “default

theme” concept (Drupal 5)

Views_templater() function to simplify template.php

code

Drupal 6 has much better theming support

through the use of hierarchical themes

Page 11: Dn D Custom 1

Allows user to pull in “related” information

Nodes need to use some form of relational linking to

join them together

Node_family set of modules or CCK nodereference

field are currently supported – but most cases you

will want to use nodereference field

Examples: numerous examples on http://av1.umg

Page 12: Dn D Custom 1

Simply ORs multiple views together (Exercise 8)

A bit tricky when using views with arguments or

exposed filters

Drupal 6: both views_union and views_fusion

modules have been made obsolete by Drupal 6

as Views 2 handles node relationships. This is a

VERY good thing as both these modules are a bit

flaky.

Page 13: Dn D Custom 1
Page 14: Dn D Custom 1

An action is a specially written PHP function whose parameters are configured through the web.

Action templates may be added by other modules and then the site admin may add instances of this action by filling out template. (http://av1.workflow/admin/build/actions)

Actions include things like sending an email or changes workflow state of a node.

Modules can then call these actions when needed

Page 15: Dn D Custom 1

Workflows define “states” for different node types And then help us manage the transition of nodes

through this “state machine” Add on modules provide various functionality

driven by a node’s state – for example: Fire an action (e.g. send an email) when a node

passes from one state to another Control access privileges based on the state a node is

in

Page 16: Dn D Custom 1

“A rule-based event driven action evaluation system.”

Much different than Workflow – whereas Workflow only manages tracking a nodes states, _NG provides a configurable action system with it.

Sort of like combining Actions and Workflows – but these aren’t standard Drupal Actions – but for Drupal 6, workflow_ng will support Drupal actions.

Page 17: Dn D Custom 1

Lets you add a computed (i.e. PHP) field to a custom content type

Choose whether to store your computed field in the database.

Value of the field is set using PHP code so it can draw on anything available to Drupal: other fields the current user database tables etc.

More info: http://drupal.org/node/126522

Page 18: Dn D Custom 1

PHP Debugger (NuSphere) If you are doing code design - a debugger is your most

powerful tool LiquidCMS recommendation: phpEd

(http://www.nusphere.com/) Breakpoints, including conditional breakpoints Traverse call stack Remote debugging PHP and MySQL manuals built in Look up user defined functions, php functions, files with

simple right click DEMO

Page 19: Dn D Custom 1

Use Drupal’s multisite capabilities to help with multi-

developer environments.

Create a site folder per user: site1.jayson, site1.adam,

site1.joe

Along side: www.site1.gc.ca, stage1.intranet, etc

Each user can set specific site “variable” settings using

their custom $conf array in settings.php

Developers can add their own modules under

sites/mysite/modules folder that other users won’t see

Page 20: Dn D Custom 1

Devel Many useful tools including SQL query report www.drupal.org/project/devel

Coder Highlights proper coding style www.drupal.org/project/coder

Masquerade Easy switching between other user www.drupal.org/project/masquerade

Page 21: Dn D Custom 1

LiquidCMS Devel Modules:

Php_errors: monitors php errors which are occurring on

your site, archives a weekly list, emails report to

defined roles - www.drupal.org/project/php_errors

Mail_redirect: when using db with “live” email

addresses; this module prevents spamming users

during testing and redirects all site email to test mail

domain – see www.drupal.org/projects/mail_redirect for

more info

Page 22: Dn D Custom 1

Programatically call a view Endless uses:

Call a view inside a view template to get embedded views

Great for AJAX calls Examples:

http://av1.umg/artist/amy-winehouse http://av1.umg/search-main/ http://av1.umg/artist-news/snoop-shoots-jay-z

Page 23: Dn D Custom 1

Module adds simple calculations to a views table. You can SUM, AVERAGE, or COUNT a selection

of fields in a row, or perform the same calculations on selected columns.

Gives spreadsheet like capabilities to Table views.

Page 24: Dn D Custom 1

Exercise 1: All Widgets (all_widgets)

Basic Exercise 1a: My Widgets (admin_widgets, my_widgets)

Simple filter Exercise 2: Pick User’s Widgets (pick_widgets)

Exposed filter Exercise 3: User’s Widgets (users_widgets)

Simple argument handling Dynamic titles

Page 25: Dn D Custom 1

Exercise 4: Tabbed Widget’s (Users) Widget page with a tab for each user’s widgets

Exercise 5: MyAccount Tab (myaccount_widgets)

Add tab to existing tab sets Exercise 6: MyAccount Tab (myaccount_widgets)

Arg handling code Exercise 7: View Templates (admin_widgets2) Exercise 8: Views Union (robyn_s_admin_w)

Join 2 views together using the views_union module