to view or not to view, that is the question! - guy bedford - 27/06/2011
DESCRIPTION
A talk on Drupal module Views by Guy Bedford.TRANSCRIPT
Welcome to:
ViewsTo view or not to view?
Is that a question?
27/June/2011 Presenter: Guy Bedford
A DrupalCape Presentation by:Guy Bedford
Views and Drupal• Views and CCK most successful contrib
modules• Views is a major factor in the growth of Drupal
27/June/2011 Presenter: Guy Bedford
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.”http://2011.doitwithdrupal.com/speakers/earl-miles
Before views…
• Drupal released in 2001
• Views started in 2005
• What did they do before views?
27/June/2011 Presenter: Guy Bedford
27/June/2011 Presenter: Guy Bedford
27/June/2011 Presenter: Guy Bedford
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
27/June/2011 Presenter: Guy Bedford
Direct SQL Queries / API functions in code
• Requires programming• Need to understand the inner workings of
Drupal• Research APIs and tables• Lots of debugging• Not fun
27/June/2011 Presenter: Guy Bedford
Let’s try it
27/June/2011 Presenter: Guy Bedford
Select * from node
27/June/2011 Presenter: Guy Bedford
Select * from node_revisions
27/June/2011 Presenter: Guy Bedford
Select * from node left join node_revisions on node.vid = node_revision.vid
Now you know SQL…
SELECT node.title, node_revisions.body
FROM node
LEFT JOIN node_revisions ON node_revisions.vid = node.vid
WHERE node.type = 'news_snippet'
AND node.status = 1
ORDER BY node.created desc
LIMIT 5;
27/June/2011 Presenter: Guy Bedford
That’s it
• Not quite…– Files, images– CCK fields– Field formatters
• Views hides this all from you….• We then think in terms of ‘abstracted’ tables:
node, taxonomy, user… with all the fields immediately accessible
27/June/2011 Presenter: Guy Bedford
Views in Action
Interactive examples and methods
27/June/2011 Presenter: Guy Bedford
Views in Action
• Useful views styles• Contexts• Using views with Progressive Enhancement• Views 3 features in D7• Related content• Views for administration
27/June/2011 Presenter: Guy Bedford
Views Styles Examples
• Views Slideshow• Views Cloud Carousel
http://www.professorcloud.com/mainsite/carousel.htm
• Dynamic Display Blockhttp://themes.myalbums.biz/content/embedded-content-example
• jCarouselhttp://di.local/video/konstantin-grcic-milan2011
• Suggestions of useful modules?
27/June/2011 Presenter: Guy Bedford
Contexts
• What’s a context?• How to make category pages with them• What about block contexts?
27/June/2011 Presenter: Guy Bedford
When views styles aren’t enough – Progressive Enhancement
• Running your own JavaScript with progressive enhancement of views (templating)
– http://coryschires.com/jquery-hover-caption-plugin/
• Using semantic views– http://di.local/articles-news2/results/taxonomy:869?page=1
• Want to learn JavaScript? Endless possibilities…
27/June/2011 Presenter: Guy Bedford
D7 Views 3 new features
• Exposed Sorts, input required• No Results, header and footer pluggable (nb
URL overloading)• Clone & Reorder displays• Group By• Views OR (module for D6)• Support for other databases
27/June/2011 Presenter: Guy Bedford
Related Content
• Related content with node reference (preferable)
• Related content by taxonomy• Views 2 snippets:
http://drupal.org/node/578038,
$node = node_load(arg(1)); if(isset($node->taxonomy)) { foreach($node->taxonomy as $term){ $terms[] = $term->tid; } return implode('+', $terms);
27/June/2011 Presenter: Guy Bedford
Some other useful modules
• View Field (views in views and on content)• Views grouping – row grouping and query
grouping.• Views PHP
27/June/2011 Presenter: Guy Bedford
Views for Administration
• Much better administration pages with tables and exposed filters
• Drupal node administration isn’t ideal• It doesn’t take long to give your clients custom
admin pages, but saves a lot of time in editing• Bulk Operations with Rules, Views Bonus Pack
(CSV, DOC, XML Export D6)• DI: admin/products, admin/users
27/June/2011 Presenter: Guy Bedford
Thank you
Questions and Suggestions Welcome
27/June/2011 Presenter: Guy Bedford