Dn D Custom 1


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • table, list and teaser views View tabs Argument handling Views templating/theming filters and exposed filters Views Modules: View calc fusion and union of views usernodes Non-Views: Actions, workflow, workflow_ng CCK Computed field Advanced: views_build_view function and how to use views in ways you'd never think of query substitution - when you can't quite get it right. ajax and views
  • Dn D Custom 1

    1. 2. <ul><li>Setup, Intro </li></ul><ul><li>Views </li></ul><ul><ul><li>Basics </li></ul></ul><ul><ul><li>Argument Handling </li></ul></ul><ul><ul><li>Tabbed Views </li></ul></ul><ul><ul><li>Templating </li></ul></ul><ul><ul><li>Fusion / Union </li></ul></ul><ul><li>A Break From Views </li></ul><ul><ul><li>Actions </li></ul></ul><ul><ul><li>Workflow </li></ul></ul><ul><ul><li>Workflow_NG </li></ul></ul><ul><ul><li>CCK Computed Field (time permitting) </li></ul></ul><ul><li>Development Tips </li></ul><ul><ul><li>phpED demo </li></ul></ul><ul><ul><li>Multisite for Multi-User </li></ul></ul><ul><li>More Views (time permitting) </li></ul><ul><ul><li>Views_build_view() </li></ul></ul><ul><ul><li>Views and AJAX </li></ul></ul><ul><ul><li>Views_Calc </li></ul></ul>Morning : 8 to 12 Afternoon : 1 to 5 BREAK BREAK LUNCH
    2. 3. <ul><li>What is VIEWS? http://av1.example1/admin/build/views/add </li></ul><ul><ul><li>A smart SQL query builder (plus extras) </li></ul></ul><ul><ul><li>By default – “a view is a list of ALL site nodes” … but… </li></ul></ul><ul><ul><li>… this is more useful when we FILTER to show only specific nodes </li></ul></ul><ul><ul><li>Arguments and filters can be set to limit which nodes to “list” </li></ul></ul><ul><ul><li>Can also: </li></ul></ul><ul><ul><ul><li>select which fields to use </li></ul></ul></ul><ul><ul><ul><li>sort </li></ul></ul></ul><ul><ul><ul><li>theme </li></ul></ul></ul>
    3. 4. <ul><li>Keep in mind – views lists nodes. (Exercise 1, 1a) </li></ul><ul><li>Drupal saying: “everything’s a node” … but, of course, not really everything… </li></ul><ul><li>Lots of things in Drupal aren’t natively nodes” </li></ul><ul><ul><li>Users </li></ul></ul><ul><ul><li>Taxonomy terms </li></ul></ul><ul><ul><li>Comments </li></ul></ul><ul><ul><li>And others </li></ul></ul><ul><li>But there are modules to make most of these things into nodes… so then they can be used with views..  </li></ul>
    4. 5. <ul><li>Page or Block </li></ul><ul><ul><li>Very similar except Block Views automatically show in the Block admin page so block functions apply (page filters, per theme, weightings, etc) </li></ul></ul><ul><li>View Type </li></ul><ul><ul><li>List ( ALWAYS use this to theme ) </li></ul></ul><ul><ul><li>Table – nice if you want to throw together a quick table </li></ul></ul><ul><ul><li>Teaser – very handy if you theme a teaser (contemplate) and have many views that use same teaser template </li></ul></ul><ul><ul><li>Other modules can add other types (RSS, etc) </li></ul></ul>
    5. 6. <ul><li>Fields – Table and List only </li></ul><ul><ul><li>Pick which fields to show on your view </li></ul></ul><ul><li>Filters and Arguments </li></ul><ul><ul><li>Pick which nodes to show </li></ul></ul><ul><ul><li>Arguments: use $_GET (i.e. URL) to pass arguments to use for filtering (more on this later) </li></ul></ul><ul><li>Exposed Filters </li></ul><ul><ul><li>Let users chose filtering options (Exercise 2) </li></ul></ul><ul><li>Sort </li></ul>
    6. 7. <ul><li>Arguments are basically filters </li></ul><ul><li>But we can take arguments from URL to use in our filters (Exercise 3) </li></ul><ul><ul><li>Why take instead of pass ? Block views can also read from URL </li></ul></ul><ul><li>Argument handling code (PHP) allows us to convert argument into what the filter is designed to handle </li></ul><ul><ul><li>Think of: better to have URL with text but need ID for filter. </li></ul></ul><ul><li>But also other uses: </li></ul><ul><ul><li>Embed into the views array ( http://av1.eclipse/archived ) </li></ul></ul><ul><ul><li>Handle end cases – i.e. filter bad arguments ( http://av1.training/user/blah/my_widgets ) (Exercise 6) </li></ul></ul>
    7. 8. <ul><li>Used to collect multiple views together on single page (Exercise 4) </li></ul><ul><li>Views automatically builds tabbed pages for you based on path provided </li></ul><ul><li>Can also add to existing pages such as User, or other existing tabs created by 3 rd party modules (Exercise 5) </li></ul>
    8. 9. <ul><li>Easiest approach is to theme a node type’s teaser and then just use teaser views… </li></ul><ul><li>… but when that’s not enough… </li></ul><ul><li>Views provides very powerful templating support. </li></ul><ul><li>Basic approach (Exercise 7) </li></ul><ul><ul><li>List view (only LIST views work for templating) </li></ul></ul><ul><ul><li>Select required fields </li></ul></ul><ul><ul><li>Use views Theme Wizard to get code for template.php, views-list-[view_name].tpl.php, views-list-[view_name].css </li></ul></ul>
    9. 10. <ul><li>All tpl files belong in the theme folder </li></ul><ul><li>LiquidCMS Enhancements: </li></ul><ul><ul><li>Support for multiple themes by better use of “default theme” concept (Drupal 5) </li></ul></ul><ul><ul><li>Views_templater() function to simplify template.php code </li></ul></ul><ul><li>Drupal 6 has much better theming support through the use of hierarchical themes </li></ul>
    10. 11. <ul><li>Allows user to pull in “related” information </li></ul><ul><li>Nodes need to use some form of relational linking to join them together </li></ul><ul><li>Node_family set of modules or CCK nodereference field are currently supported – but most cases you will want to use nodereference field </li></ul><ul><li>Examples: numerous examples on http://av1.umg </li></ul>
    11. 12. <ul><li>Simply ORs multiple views together (Exercise 8) </li></ul><ul><li>A bit tricky when using views with arguments or exposed filters </li></ul><ul><li>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. </li></ul>
    12. 14. <ul><li>An action is a specially written PHP function whose parameters are configured through the web. </li></ul><ul><li>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 ) </li></ul><ul><li>Actions include things like sending an email or changes workflow state of a node. </li></ul><ul><li>Modules can then call these actions when needed </li></ul>
    13. 15. <ul><li>Workflows define “states” for different node types </li></ul><ul><li>And then help us manage the transition of nodes through this “state machine” </li></ul><ul><li>Add on modules provide various functionality driven by a node’s state – for example: </li></ul><ul><ul><li>Fire an action (e.g. send an email) when a node passes from one state to another </li></ul></ul><ul><ul><li>Control access privileges based on the state a node is in </li></ul></ul>
    14. 16. <ul><li>“ A rule-based event driven action evaluation system.” </li></ul><ul><li>Much different than Workflow – whereas Workflow only manages tracking a nodes states, _NG provides a configurable action system with it. </li></ul><ul><li>Sort of like combining Actions and Workflows – but these aren’t standard Drupal Actions – but for Drupal 6, workflow_ng will support Drupal actions. </li></ul>
    15. 17. <ul><li>Lets you add a computed (i.e. PHP) field to a custom content type </li></ul><ul><li>Choose whether to store your computed field in the database. </li></ul><ul><li>Value of the field is set using PHP code so it can draw on anything available to Drupal: </li></ul><ul><ul><li>other fields </li></ul></ul><ul><ul><li>the current user </li></ul></ul><ul><ul><li>database tables </li></ul></ul><ul><ul><li>etc. </li></ul></ul><ul><li>More info: http://drupal.org/node/126522 </li></ul>
    16. 18. <ul><li>PHP Debugger (NuSphere) </li></ul><ul><ul><li>If you are doing code design - a debugger is your most powerful tool </li></ul></ul><ul><ul><li>LiquidCMS recommendation: phpEd ( http://www.nusphere.com/ ) </li></ul></ul><ul><ul><ul><li>Breakpoints, including conditional breakpoints </li></ul></ul></ul><ul><ul><ul><li>Traverse call stack </li></ul></ul></ul><ul><ul><ul><li>Remote debugging </li></ul></ul></ul><ul><ul><ul><li>PHP and MySQL manuals built in </li></ul></ul></ul><ul><ul><ul><li>Look up user defined functions, php functions, files with simple right click </li></ul></ul></ul>DEMO
    17. 19. <ul><li>Use Drupal’s multisite capabilities to help with multi-developer environments. </li></ul><ul><li>Create a site folder per user: site1.jayson, site1.adam, site1.joe </li></ul><ul><ul><li>Along side: www.site1.gc.ca, stage1.intranet, etc </li></ul></ul><ul><li>Each user can set specific site “variable” settings using their custom $conf array in settings.php </li></ul><ul><li>Developers can add their own modules under sites/mysite/modules folder that other users won’t see </li></ul>
    18. 20. <ul><li>Devel </li></ul><ul><ul><li>Many useful tools including SQL query report </li></ul></ul><ul><ul><li>www.drupal.org/project/devel </li></ul></ul><ul><li>Coder </li></ul><ul><ul><li>Highlights proper coding style </li></ul></ul><ul><ul><li>www.drupal.org/project/coder </li></ul></ul><ul><li>Masquerade </li></ul><ul><ul><li>Easy switching between other user </li></ul></ul><ul><ul><li>www.drupal.org/project/masquerade </li></ul></ul>
    19. 21. <ul><li>LiquidCMS Devel Modules: </li></ul><ul><ul><li>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 </li></ul></ul><ul><ul><li>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 </li></ul></ul>
    20. 22. <ul><li>Programatically call a view </li></ul><ul><li>Endless uses: </li></ul><ul><ul><li>Call a view inside a view template to get embedded views </li></ul></ul><ul><ul><li>Great for AJAX calls </li></ul></ul><ul><li>Examples: </li></ul><ul><ul><li>http://av1.umg/artist/amy-winehouse </li></ul></ul><ul><ul><li>http://av1.umg/search-main/ </li></ul></ul><ul><ul><li>http://av1.umg/artist-news/snoop-shoots-jay-z </li></ul></ul>
    21. 23. <ul><li>Module adds simple calculations to a views table. </li></ul><ul><li>You can SUM, AVERAGE, or COUNT a selection of fields in a row, or perform the same calculations on selected columns. </li></ul><ul><li>Gives spreadsheet like capabilities to Table views. </li></ul>
    22. 24. <ul><li>Exercise 1: All Widgets (all_widgets) </li></ul><ul><ul><li>Basic </li></ul></ul><ul><li>Exercise 1a: My Widgets (admin_widgets, my_widgets) </li></ul><ul><ul><li>Simple filter </li></ul></ul><ul><li>Exercise 2: Pick User’s Widgets (pick_widgets) </li></ul><ul><ul><li>Exposed filter </li></ul></ul><ul><li>Exercise 3: User’s Widgets (users_widgets) </li></ul><ul><ul><li>Simple argument handling </li></ul></ul><ul><ul><li>Dynamic titles </li></ul></ul>
    23. 25. <ul><li>Exercise 4: Tabbed Widget’s (Users) </li></ul><ul><ul><li>Widget page with a tab for each user’s widgets </li></ul></ul><ul><li>Exercise 5: MyAccount Tab (myaccount_widgets) </li></ul><ul><ul><li>Add tab to existing tab sets </li></ul></ul><ul><li>Exercise 6: MyAccount Tab (myaccount_widgets) </li></ul><ul><ul><li>Arg handling code </li></ul></ul><ul><li>Exercise 7: View Templates (admin_widgets2) </li></ul><ul><li>Exercise 8: Views Union (robyn_s_admin_w) </li></ul><ul><ul><li>Join 2 views together using the views_union module </li></ul></ul>