To View Or Not To View, That Is The Question! - Guy Bedford - 27/06/2011


Published on

A talk on Drupal module Views by Guy Bedford.

Published in: Technology, Sports
  • 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

To View Or Not To View, That Is The Question! - Guy Bedford - 27/06/2011

  1. 1. Welcome to: Views To view or not to view? Is that a question? 27/June/2011 Presenter: Guy Bedford A DrupalCape Presentation by: Guy Bedford
  2. 2. Views and Drupal <ul><li>Views and CCK most successful contrib modules </li></ul><ul><li>Views is a major factor in the growth of Drupal </li></ul>27/June/2011 Presenter: Guy Bedford
  3. 3. Angry Donuts 27/June/2011 Presenter: Guy Bedford “ Earl Miles is a permanent member and founder of the Drupal Association. In 2005, Earl found Drupal and thought it was exactly the kind of thing that he wanted for a website he was building in his spare time. Then he found out that Drupal lacked a couple of features here and there; so Earl ignored work for about three weeks and created the Views module, which has been instrumental in Drupal's continued growth.”
  4. 4. Before views… <ul><li>Drupal released in 2001 </li></ul><ul><li>Views started in 2005 </li></ul><ul><li>What did they do before views? </li></ul>27/June/2011 Presenter: Guy Bedford
  5. 5. 27/June/2011 Presenter: Guy Bedford
  6. 6. 27/June/2011 Presenter: Guy Bedford
  7. 7. Before views… 27/June/2011 Presenter: Guy Bedford SELECT node.nid AS nid, node.title AS node_title, node_data_field_longteaser.field_longteaser_value AS node_data_field_longteaser_field_longteaser_value, node_data_field_longteaser.field_longteaser_format AS node_data_field_longteaser_field_longteaser_format, node.type AS node_type, node.vid AS node_vid, node_data_field_teaserdescription.field_teaserdescription_value AS node_data_field_teaserdescription_field_teaserdescription_value, node_data_field_longteaser.field_artilcleleadimage_fid AS node_data_field_longteaser_field_artilcleleadimage_fid, node_data_field_longteaser.field_artilcleleadimage_list AS node_data_field_longteaser_field_artilcleleadimage_list, node_data_field_longteaser.field_artilcleleadimage_data AS node_data_field_longteaser_field_artilcleleadimage_data, node_data_field_leadimage.field_leadimage_fid AS node_data_field_leadimage_field_leadimage_fid, node_data_field_leadimage.field_leadimage_list AS node_data_field_leadimage_field_leadimage_list, node_data_field_leadimage.field_leadimage_data AS node_data_field_leadimage_field_leadimage_data, node.created AS node_created FROM node node LEFT JOIN content_field_di_featurecb node_data_field_di_featurecb ON node.vid = node_data_field_di_featurecb.vid LEFT JOIN content_field_frontpage node_data_field_frontpage ON node.vid = node_data_field_frontpage.vid LEFT JOIN content_type_article node_data_field_longteaser ON node.vid = node_data_field_longteaser.vid LEFT JOIN content_field_teaserdescription node_data_field_teaserdescription ON node.vid = node_data_field_teaserdescription.vid LEFT JOIN content_field_leadimage node_data_field_leadimage ON node.vid = node_data_field_leadimage.vid WHERE (node.status <> 0) AND (node.type in ('article', 'news_snippet', 'showcase', 'speaker_presentation')) AND ((node_data_field_di_featurecb.field_di_featurecb_value) != ('Yes, this is a front page feature')) AND ((node_data_field_frontpage.field_frontpage_value) = ('Yes, this should feature in the front page feed')) ORDER BY node_created DESC
  8. 8. 27/June/2011 Presenter: Guy Bedford
  9. 9. Direct SQL Queries / API functions in code <ul><li>Requires programming </li></ul><ul><li>Need to understand the inner workings of Drupal </li></ul><ul><li>Research APIs and tables </li></ul><ul><li>Lots of debugging </li></ul><ul><li>Not fun </li></ul>27/June/2011 Presenter: Guy Bedford
  10. 10. Let’s try it 27/June/2011 Presenter: Guy Bedford Select * from node
  11. 11. 27/June/2011 Presenter: Guy Bedford Select * from node_revisions
  12. 12. 27/June/2011 Presenter: Guy Bedford Select * from node left join node_revisions on node.vid = node_revision.vid
  13. 13. Now you know SQL… <ul><li>SELECT node.title, node_revisions.body </li></ul><ul><li>FROM node </li></ul><ul><li>LEFT JOIN node_revisions ON node_revisions.vid = node.vid </li></ul><ul><li>WHERE node.type = 'news_snippet' </li></ul><ul><li>AND node.status = 1 </li></ul><ul><li>ORDER BY node.created desc </li></ul><ul><li>LIMIT 5; </li></ul>27/June/2011 Presenter: Guy Bedford
  14. 14. That’s it <ul><li>Not quite… </li></ul><ul><ul><li>Files, images </li></ul></ul><ul><ul><li>CCK fields </li></ul></ul><ul><ul><li>Field formatters </li></ul></ul><ul><li>Views hides this all from you…. </li></ul><ul><li>We then think in terms of ‘abstracted’ tables: node, taxonomy, user… with all the fields immediately accessible </li></ul>27/June/2011 Presenter: Guy Bedford
  15. 15. Views in Action Interactive examples and methods 27/June/2011 Presenter: Guy Bedford
  16. 16. Views in Action <ul><li>Useful views styles </li></ul><ul><li>Contexts </li></ul><ul><li>Using views with Progressive Enhancement </li></ul><ul><li>Views 3 features in D7 </li></ul><ul><li>Related content </li></ul><ul><li>Views for administration </li></ul>27/June/2011 Presenter: Guy Bedford
  17. 17. Views Styles Examples <ul><li>Views Slideshow </li></ul><ul><li>Views Cloud Carousel </li></ul><ul><li>Dynamic Display Block </li></ul><ul><li>jCarousel http://di.local/video/konstantin-grcic-milan2011 </li></ul><ul><li>Suggestions of useful modules? </li></ul>27/June/2011 Presenter: Guy Bedford
  18. 18. Contexts <ul><li>What’s a context? </li></ul><ul><li>How to make category pages with them </li></ul><ul><li>What about block contexts? </li></ul>27/June/2011 Presenter: Guy Bedford
  19. 19. When views styles aren’t enough – Progressive Enhancement <ul><li>Running your own JavaScript with progressive enhancement of views (templating) </li></ul><ul><ul><li> </li></ul></ul><ul><li>Using semantic views </li></ul><ul><ul><li>http://di.local/articles-news2/results/taxonomy:869?page=1 </li></ul></ul><ul><li>Want to learn JavaScript? Endless possibilities… </li></ul>27/June/2011 Presenter: Guy Bedford
  20. 20. D7 Views 3 new features <ul><li>Exposed Sorts, input required </li></ul><ul><li>No Results, header and footer pluggable (nb URL overloading) </li></ul><ul><li>Clone & Reorder displays </li></ul><ul><li>Group By </li></ul><ul><li>Views OR (module for D6) </li></ul><ul><li>Support for other databases </li></ul>27/June/2011 Presenter: Guy Bedford
  21. 21. Related Content <ul><li>Related content with node reference (preferable) </li></ul><ul><li>Related content by taxonomy </li></ul><ul><li>Views 2 snippets: , </li></ul><ul><li>$node = node_load(arg(1)); </li></ul><ul><li>if(isset($node->taxonomy)) { </li></ul><ul><li>foreach($node->taxonomy as $term){ </li></ul><ul><li>$terms[] = $term->tid; </li></ul><ul><li>} </li></ul><ul><li>return implode('+', $terms); </li></ul>27/June/2011 Presenter: Guy Bedford
  22. 22. Some other useful modules <ul><li>View Field (views in views and on content) </li></ul><ul><li>Views grouping – row grouping and query grouping. </li></ul><ul><li>Views PHP </li></ul>27/June/2011 Presenter: Guy Bedford
  23. 23. Views for Administration <ul><li>Much better administration pages with tables and exposed filters </li></ul><ul><li>Drupal node administration isn’t ideal </li></ul><ul><li>It doesn’t take long to give your clients custom admin pages, but saves a lot of time in editing </li></ul><ul><li>Bulk Operations with Rules, Views Bonus Pack (CSV, DOC, XML Export D6) </li></ul><ul><li>DI: admin/products, admin/users </li></ul>27/June/2011 Presenter: Guy Bedford
  24. 24. Thank you Questions and Suggestions Welcome 27/June/2011 Presenter: Guy Bedford