Jay Callicott Drupal Views 2.0 Presentation
- 1. Getting the most out of Views 2.0Jay CallicottSeptember 19, 2009Drupal Camp Atlanta
- 2. Introduction: Session OutlineIntroduction to Views 2.0Why views?Advantages of using views over database queriesDb query vs Views side by side comparisonTheme-centric vs Logic-centric approaches to view creationA case study on 2 main strategies for creating viewsViews 2.0 Wrap Up & Q&A
- 3. Introduction: Informal PollHow many beginner Drupal developers?Advanced?How many non-developers?How many here came to the conference for kicking the tires of Drupal?Training?
- 4. Introduction: Intended AudienceBeginner to advanced developersThe material is more advanced but I will try to not lose beginnersBusiness Guys (Managers/Owners/CIOs) wanting to learn the power of Drupal
- 5. Introduction: Who Am I?Jay CallicottMediacurrent web developerDrupal developer since 4.6Started using Drupal in a part-time business I started several years agoDeveloped web applications for the state of Arkansas before this jobExpert in PHP/mySQL and Drupal as wellworked with Drupal versions: 4.6 / 4.7 / 5 / now 6
- 6. Introduction: What are views?Views are a critical feature of DrupalAs big as CCK, robust theming layer, modular framework*Will be rolled into Drupal 7.0 core*Edit, this is not correct – I think I got confused with CCK?Views are for building arbitrary lists of content.Not unlike “lists” in Sharepoint, other CMS’s might have similar conceptsViews can be blocks, pages, embeddedViews can pull any type of Drupal content (nodes/users/etc) and do some amazing things all from the UI!
- 7. Introduction: Why did I create this session?This session is more me 1 year ago.Intended for someone who has used Drupal, even beginner-level who is trying to get a grasp of Views 2.0Or for Drupal 5 developers getting a handle on the transition of Views 1.0 to 2.0Views 2.0 can look intimidating at first
- 8. Why views? Advantages of using views over database queriesThe usual alternative to views is the quick db queryFetch results in module, spit out htmlAbsolute control!Tempting if you are used to custom codingFine for quick? Or is it?As requirements grow, code grows and maintenance becomes a problemViews can do simple and can grow as requirements growViews are extremely flexible and scalable
- 11. Db query vs Views – side by side comparisonWe will go screen by screenFirst create a module using custom db querySecond create a view that does the same thing
- 39. Theme-centric vs logic-centric approach to view creationMethodology is criticalEspecially with large projectsViews 2.0 methodology approaches: look & feel or logicDocumentation covers nuts & bolts, not strategyViews 1.0 didn’t have this problemEach list was usually it’s own viewWith 2.0 you can combine lists together
- 40. Theme-centric – aka look & feelSimple listAdd displays for recent articles, recommended articles, popular, gear items, speciesAll displays get rolled up into 1 viewImage listImage on leftTitle, additional fields on the rightFeatured item1 content item from a content type, big image, more fields, etc.
- 41. Logic-centric methodologyRecent articlesAdd displays for species articles, gear articles / add displays for blocks / pagesMost popularAdd displays for species / gear / hunting / etcRelated articlesGear, hunting articles that have a certain taxonomy term passed in through an argumentE.g. you pass in ‘deer’, ‘fish’, whatever and get articles that have that term
- 42. Comparing the 2 approachesBoth approaches sound reasonableMy experience building around look & feel is much more maintainable and is more sustainableLogic approach can lead to much frustration
- 43. Comparing Approaches: L&FSharing templates is easierLook is the same/similar you should share CSSWon’t have to branch off .tpl templates for different content
- 44. Comparing Approaches: LogicMaybe share templatesWhat if the logic is similar but the look is different?Some displays might be pages, some blocksYou could be forced to create a bunch of templatesTemplate explosion can occur!
- 45. More on Logic regarding templates and CSSYou have a recent articles block and a popular articles block across 2 views.Both have same look = similar .tpls and duplicated effortsBloated CSSViews have different ids/classes (will show example later)Template DuplicationSimilar templates are createdTemplate customization gets duplicatedMaintenance becomes a nightmare
- 46. Comparing Approaches: L&F v. LogicLook & FeelYou will override fields and some filtersAll the styles will be the same = consistencyLogicYou often override more here than in look & feel approachMaybe styles and filters and fieldsViews become very hard to maintain!
- 57. Wrap-upCovered basics of views, in detail why we should use them over custom codeShowed side-by-side how creating a view over code is often preferredCovered 2 main approaches or strategies when creating views and the implications of these 2 main approachesDisplayed a real-world scenario and explained implications for each strategy
- 58. Q&ACan views do ‘X/Y/Z’?Your specific business problem, can views help?General questions about Drupal? Mediacurrent?Got more questions later?Jay.callicott@mediacurrent.comor twitter http://twitter.com/drupalninjaThanks for coming!