Introduction to Drupal 7                      Session 3.2           News section and home page block                      ...
Agenda•    What is Views•    Common uses•    Administration overviews•    Case study – making dynamic news section     and...
What is Views• The most popular Drupal module enabling  regular (and not-technical) users to make lists,  tables and other...
Views common use cases• From http://drupal.org/project/views:       – You like the default front page view, but you find y...
Views administration overview• Administration > Structure > Views• URL: admin/structure/viewsDrupalist: Kalin Chernev   Co...
Creating latest news section• Prerequisites for making it happen:       – Specific content type which will populate the   ...
Creating latest news section, step 1• Administration > Structure > Views > Add new  view• URL: admin/structure/views/addDr...
Creating latest news section, step 2Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   8
Working with the controls• Adding fields, criteria, etc       – You can use the add button directly• Rearranging fields   ...
Creating latest news section, step 3Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   10
Format settings explained• Main format: table (easiest to use for  beginners)• Title, date and body are grouped with <br/>...
Fields settings explained• We added the following fields: news image, node  title, original publish date and the body of t...
Filter and sort criteria explained• 2 filter criteria are used for our case:       – Content: Published (Yes) which filter...
Page settings explained•    Path: this is the URL which the page receives•    Menu: use if you want to place the page in a...
Advanced settings explained                                                                     •   Contextual filters: us...
What would an advanced user do• Name your view better: for example ‘News  views page’ instead of just ‘Page’• Give a bette...
Your dynamic news section is readyDrupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   17
Compile your work so far• Go to admin/structure/features/create• Set a name, description and a version• Select your view a...
Adding a second view block• We want to add another view, which will be a  block, again showing the latest news items  with...
Latest news views block• Go back to your view:  admin/structure/views/view/{your_view}/edit• Click “Add” and include a new...
Important: overriding values• Click on the a field where the override will be• Select the override from the drop-downDrupa...
Deleting fields from views• You can either click on the field itself and  delete it (after overriding it)• Or you can use ...
Tweaking the latest news block viewDrupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   23
Your home page news block is readyDrupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   24
Your features is overriden• We made changes on our News view, and the  Features modules sees the changes• Therefore, if we...
Recreate the feature and save it• Change the version to be up in some wayDrupalist: Kalin Chernev   Course by Init Lab (ht...
Time for questionsDrupalist: Kalin Chernev       Course by Init Lab (http://initlab.org)   27
ContactsKalin Chernev       – E: kalata@shtrak.eu       – T: twitter.com/kalinchernev       – U: http://shtrak.eu/kalataDr...
Upcoming SlideShare
Loading in...5
×

Introduction to Drupal 7 News section and home page block with views

11,666

Published on

Views 3 module overview. Making dynamic news section with Drupal Views module.

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total Views
11,666
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
217
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide

Introduction to Drupal 7 News section and home page block with views

  1. 1. Introduction to Drupal 7 Session 3.2 News section and home page block with ViewsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
  2. 2. Agenda• What is Views• Common uses• Administration overviews• Case study – making dynamic news section and latest news block for home pageDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
  3. 3. What is Views• The most popular Drupal module enabling regular (and not-technical) users to make lists, tables and other outputs of database queries in a fun way.• What we’re going to use Views for: – Latest news section – About us section with team members – Latest news block for home pageDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
  4. 4. Views common use cases• From http://drupal.org/project/views: – You like the default front page view, but you find you want to sort it differently. – You like the default taxonomy/term view, but you find you want to sort it differently; for example, alphabetically. – You use /tracker, but you want to restrict it to posts of a certain type. – You like the idea of the article module, but it doesnt display articles the way you like. – You want a way to display a block with the 5 most recent posts of some particular type. – You want to provide unread forum posts. – You want a monthly archive similar to the typical Movable Type/Wordpress archives that displays a link to the in the form of "Month, YYYY (X)" where X is the number of posts that month, and displays them in a block. The links lead to a simple list of posts for that month.• Views can do a lot more than that, but those are some of the obvious uses of Views.Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 4
  5. 5. Views administration overview• Administration > Structure > Views• URL: admin/structure/viewsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
  6. 6. Creating latest news section• Prerequisites for making it happen: – Specific content type which will populate the section, i.e. news content type have to available – News content type will have at least these 3 fields • News image – for the news thumbnail • Original publish date • Body field or any other text area field – Views and Chaos tools modules installed  – Already populated content would a plusDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 6
  7. 7. Creating latest news section, step 1• Administration > Structure > Views > Add new view• URL: admin/structure/views/addDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
  8. 8. Creating latest news section, step 2Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 8
  9. 9. Working with the controls• Adding fields, criteria, etc – You can use the add button directly• Rearranging fields – Use the options arrow on the add buttonDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
  10. 10. Creating latest news section, step 3Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
  11. 11. Format settings explained• Main format: table (easiest to use for beginners)• Title, date and body are grouped with <br/> in the endDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
  12. 12. Fields settings explained• We added the following fields: news image, node title, original publish date and the body of the node;• The order of the fields is important;• The news image takes the news image preset;• The node title links to the node itself;• The publish date is long format;• The body field is trimmed version to 500 symbols;• No field labels are needed for this case;Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 12
  13. 13. Filter and sort criteria explained• 2 filter criteria are used for our case: – Content: Published (Yes) which filters the content in such a way, that only nodes that are made available for public will be available – Content: Type (=News) which filters the content displayed to be only of type News• 1 sorting criteria is used for our case: – Content: Post date (desc) which makes so that the latest content is placed on topDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 13
  14. 14. Page settings explained• Path: this is the URL which the page receives• Menu: use if you want to place the page in a menu item, i.e. in the main menu• Access: rarely used, if you want to directly place some permissions on the section• Header: used to place text/view before the result view• Footer: used to place text/view after the result view• Pager: self-explanatory – used to make pagers for your views section• More link: used in views blocks mainlyDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
  15. 15. Advanced settings explained • Contextual filters: used when dynamic arguments are passed from the URL for node id or user id • Relationships: used when you need data from a database table, which is not accessible in your current state • No results behavior: place text/view for cases when your query does not give results • Exposed form: used when your filter criteria are exposed • Other – Machine name: important when you have many views – Query settings: removing duplicates happen from here – Caching: when you want to make performance tunings – CSS class: helping themers – Theme: advanced themingDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15
  16. 16. What would an advanced user do• Name your view better: for example ‘News views page’ instead of just ‘Page’• Give a better machine readable name, for example ‘news_views_page’ instead of ‘page‘• You can also tweak the table fields a bit, this is optional• To become and advanced user: play with the views settings as much as you can;Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 16
  17. 17. Your dynamic news section is readyDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 17
  18. 18. Compile your work so far• Go to admin/structure/features/create• Set a name, description and a version• Select your view and image style newsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 18
  19. 19. Adding a second view block• We want to add another view, which will be a block, again showing the latest news items with a title and some text, no image or date• The block will be used for the front page• We can reuse some logic from our first view• We’ll learn how to override views configurationsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 19
  20. 20. Latest news views block• Go back to your view: admin/structure/views/view/{your_view}/edit• Click “Add” and include a new views Block• The blocks automatically takes most of your views page configurations• Override the following: – The display name of the view – Remove the fields you don’t need – Limit the number of items to display to 5 – Change the machine readable name – Give a block name in the block settingsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 20
  21. 21. Important: overriding values• Click on the a field where the override will be• Select the override from the drop-downDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 21
  22. 22. Deleting fields from views• You can either click on the field itself and delete it (after overriding it)• Or you can use the Arrange optionDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 22
  23. 23. Tweaking the latest news block viewDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 23
  24. 24. Your home page news block is readyDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 24
  25. 25. Your features is overriden• We made changes on our News view, and the Features modules sees the changes• Therefore, if we work with a repository, the repository has be updated with our latest changes version (adding the views block)Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 25
  26. 26. Recreate the feature and save it• Change the version to be up in some wayDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 26
  27. 27. Time for questionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 27
  28. 28. ContactsKalin Chernev – E: kalata@shtrak.eu – T: twitter.com/kalinchernev – U: http://shtrak.eu/kalataDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 28
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×