SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Downloaden Sie, um offline zu lesen
Introduction to Drupal 7

                      Session 3.2
           News section and home page block
                      with Views


Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   1
Agenda
•    What is Views
•    Common uses
•    Administration overviews
•    Case study – making dynamic news section
     and latest news block for home page




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   2
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 page

Drupalist: Kalin Chernev     Course by Init Lab (http://initlab.org)   3
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 doesn't 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
Views administration overview
• Administration > Structure > Views
• URL: admin/structure/views




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   5
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 plus

Drupalist: Kalin Chernev      Course by Init Lab (http://initlab.org)   6
Creating latest news section, step 1
• Administration > Structure > Views > Add new
  view
• URL: admin/structure/views/add




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   7
Creating latest news section, step 2




Drupalist: 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
       – Use the options arrow on the add button




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   9
Creating latest news section, step 3




Drupalist: 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/> in
  the end




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   11
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
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 top

Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   13
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 mainly


Drupalist: Kalin Chernev        Course by Init Lab (http://initlab.org)                   14
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 theming




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)                                    15
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
Your dynamic news section is ready




Drupalist: 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 and image style news




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   18
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
  configurations


Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   19
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 settings


Drupalist: Kalin Chernev     Course by Init Lab (http://initlab.org)   20
Important: overriding values
• Click on the a field where the override will be
• Select the override from the drop-down




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   21
Deleting fields from views
• You can either click on the field itself and
  delete it (after overriding it)
• Or you can use the Arrange option




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   22
Tweaking the latest news block view




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   23
Your home page news block is ready




Drupalist: 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 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
Recreate the feature and save it
• Change the version to be up in some way




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   26
Time for questions




Drupalist: Kalin Chernev       Course by Init Lab (http://initlab.org)   27
Contacts
Kalin Chernev
       – E: kalata@shtrak.eu
       – T: twitter.com/kalinchernev
       – U: http://shtrak.eu/kalata




Drupalist: Kalin Chernev   Course by Init Lab (http://initlab.org)   28

Weitere ähnliche Inhalte

Was ist angesagt?

My site is slow
My site is slowMy site is slow
My site is slow
hernanibf
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp London
hernanibf
 

Was ist angesagt? (14)

NoSQL, Apache SOLR and Apache Hadoop
NoSQL, Apache SOLR and Apache HadoopNoSQL, Apache SOLR and Apache Hadoop
NoSQL, Apache SOLR and Apache Hadoop
 
YAG - Yet Another Gallery
YAG - Yet Another GalleryYAG - Yet Another Gallery
YAG - Yet Another Gallery
 
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015Drupal8 themingdeepdive drupaldevdays-montpellier17042015
Drupal8 themingdeepdive drupaldevdays-montpellier17042015
 
Evolution of Drupal and the Drupal community
Evolution of Drupal and the Drupal communityEvolution of Drupal and the Drupal community
Evolution of Drupal and the Drupal community
 
Drupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin SystemDrupal 8 Deep Dive: Plugin System
Drupal 8 Deep Dive: Plugin System
 
Java EE revisits design patterns
Java EE revisits design patternsJava EE revisits design patterns
Java EE revisits design patterns
 
Java EE Revisits Design Patterns
Java EE Revisits Design PatternsJava EE Revisits Design Patterns
Java EE Revisits Design Patterns
 
My site is slow
My site is slowMy site is slow
My site is slow
 
เพาเวอร์พอย Wordpress3 5-1
เพาเวอร์พอย Wordpress3 5-1เพาเวอร์พอย Wordpress3 5-1
เพาเวอร์พอย Wordpress3 5-1
 
One Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp LondonOne Drupal to rule them all - Drupalcamp London
One Drupal to rule them all - Drupalcamp London
 
WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2WordPress Theme Design and Development Workshop - Day 2
WordPress Theme Design and Development Workshop - Day 2
 
Android intents-3 www.j2program.blogspot.com
Android intents-3 www.j2program.blogspot.comAndroid intents-3 www.j2program.blogspot.com
Android intents-3 www.j2program.blogspot.com
 
Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8Top 8 Improvements in Drupal 8
Top 8 Improvements in Drupal 8
 
Getting started with rails active storage wae
Getting started with rails active storage waeGetting started with rails active storage wae
Getting started with rails active storage wae
 

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

Ähnlich wie Introduction to Drupal 7 News section and home page block with views (20)

Introduction to Drupal 7 - Content types and fields
Introduction to Drupal 7 - Content types and fieldsIntroduction to Drupal 7 - Content types and fields
Introduction to Drupal 7 - Content types and fields
 
Introduction to Drupal 7 - Blocks management and contexts
Introduction to Drupal 7 - Blocks management and contextsIntroduction to Drupal 7 - Blocks management and contexts
Introduction to Drupal 7 - Blocks management and contexts
 
Introduction to Drupal 7 Themes and design
Introduction to Drupal 7 Themes and designIntroduction to Drupal 7 Themes and design
Introduction to Drupal 7 Themes and design
 
Introduction to Drupal 7 Users and roles management
Introduction to Drupal 7 Users and roles managementIntroduction to Drupal 7 Users and roles management
Introduction to Drupal 7 Users and roles management
 
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patchesIntroduction to Drupal 7 - Updating core, themes and modules. applying patches
Introduction to Drupal 7 - Updating core, themes and modules. applying patches
 
Drupal: an Overview
Drupal: an OverviewDrupal: an Overview
Drupal: an Overview
 
Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2Blisstering drupal module development ppt v1.2
Blisstering drupal module development ppt v1.2
 
Drupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 versionDrupal upgrades and migrations. BAD Camp 2013 version
Drupal upgrades and migrations. BAD Camp 2013 version
 
Drupal -Introduction to Drupal
Drupal -Introduction to DrupalDrupal -Introduction to Drupal
Drupal -Introduction to Drupal
 
Drupal intro
Drupal introDrupal intro
Drupal intro
 
Drupal intro
Drupal introDrupal intro
Drupal intro
 
Synapse india reviews on drupal intro
Synapse india reviews on drupal introSynapse india reviews on drupal intro
Synapse india reviews on drupal intro
 
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
Drupaldelphia 2013 Presentation- Making Your Site more Friendly to Search Eng...
 
Drupal intro (1)
Drupal intro (1)Drupal intro (1)
Drupal intro (1)
 
Introduction to Drupal 7 - Taxonomy Categorization - Homework included
Introduction to Drupal 7 - Taxonomy Categorization - Homework includedIntroduction to Drupal 7 - Taxonomy Categorization - Homework included
Introduction to Drupal 7 - Taxonomy Categorization - Homework included
 
Introduction to Drupal 7 - Making a slideshow with Views 3
Introduction to Drupal 7 - Making a slideshow with Views 3Introduction to Drupal 7 - Making a slideshow with Views 3
Introduction to Drupal 7 - Making a slideshow with Views 3
 
Introduction to Drupal 7 - Basic Functionalities and Content management
Introduction to Drupal 7 - Basic Functionalities and Content managementIntroduction to Drupal 7 - Basic Functionalities and Content management
Introduction to Drupal 7 - Basic Functionalities and Content management
 
Rapid site production with Drupal
Rapid site production with DrupalRapid site production with Drupal
Rapid site production with Drupal
 
Why Drupal?
Why Drupal?Why Drupal?
Why Drupal?
 
Drupal intro-training-in-mumbai
Drupal intro-training-in-mumbaiDrupal intro-training-in-mumbai
Drupal intro-training-in-mumbai
 

Mehr von Kalin Chernev

Drupal course-plovdiv-week1-day-1
Drupal course-plovdiv-week1-day-1Drupal course-plovdiv-week1-day-1
Drupal course-plovdiv-week1-day-1
Kalin Chernev
 
Курс по Drupal - лекция 3
Курс по Drupal - лекция 3Курс по Drupal - лекция 3
Курс по Drupal - лекция 3
Kalin Chernev
 

Mehr von Kalin Chernev (20)

Style guides in drupal development workflows
Style guides in drupal development workflowsStyle guides in drupal development workflows
Style guides in drupal development workflows
 
RESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-sRESTful with Drupal - in-s and out-s
RESTful with Drupal - in-s and out-s
 
Trainings and education at hackerspaces
Trainings and education at hackerspacesTrainings and education at hackerspaces
Trainings and education at hackerspaces
 
Introduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS FundamentalsIntroduction to Frontend Development - Session 2 - CSS Fundamentals
Introduction to Frontend Development - Session 2 - CSS Fundamentals
 
Introduction to Frontend Development - Session 1 - HTML Fundamentals
Introduction to Frontend Development - Session 1 - HTML FundamentalsIntroduction to Frontend Development - Session 1 - HTML Fundamentals
Introduction to Frontend Development - Session 1 - HTML Fundamentals
 
SEO Fundamentals Outline Lecture 2
SEO Fundamentals Outline Lecture 2SEO Fundamentals Outline Lecture 2
SEO Fundamentals Outline Lecture 2
 
Search Engine Optimization Fundamentals
Search Engine Optimization FundamentalsSearch Engine Optimization Fundamentals
Search Engine Optimization Fundamentals
 
Hackerspaces in Bulgaria Lecture VarnaConf 2012
Hackerspaces in Bulgaria Lecture VarnaConf 2012Hackerspaces in Bulgaria Lecture VarnaConf 2012
Hackerspaces in Bulgaria Lecture VarnaConf 2012
 
Introduction to Drupal 7 - SEO
Introduction to Drupal 7 - SEOIntroduction to Drupal 7 - SEO
Introduction to Drupal 7 - SEO
 
Introduction to Drupal 7 - Homework - webforms on webforms
Introduction to Drupal 7 - Homework - webforms on webformsIntroduction to Drupal 7 - Homework - webforms on webforms
Introduction to Drupal 7 - Homework - webforms on webforms
 
Introduction to Drupal 7 - Webforms
Introduction to Drupal 7 - WebformsIntroduction to Drupal 7 - Webforms
Introduction to Drupal 7 - Webforms
 
Introduction to Drupal 7 - Installing and configuring WYSIWYG editors in Drupal
Introduction to Drupal 7 - Installing and configuring WYSIWYG editors in DrupalIntroduction to Drupal 7 - Installing and configuring WYSIWYG editors in Drupal
Introduction to Drupal 7 - Installing and configuring WYSIWYG editors in Drupal
 
Introduction to Drupal 7 - Homework on making latest news slideshow block
Introduction to Drupal 7 - Homework on making latest news slideshow blockIntroduction to Drupal 7 - Homework on making latest news slideshow block
Introduction to Drupal 7 - Homework on making latest news slideshow block
 
Introduction to Drupal 7 - Homework - making team section
Introduction to Drupal 7 - Homework - making team sectionIntroduction to Drupal 7 - Homework - making team section
Introduction to Drupal 7 - Homework - making team section
 
Introduction to Drupal 7 - Image Styles
Introduction to Drupal 7 - Image StylesIntroduction to Drupal 7 - Image Styles
Introduction to Drupal 7 - Image Styles
 
Introduction to Drupal 7 - Getting Drupal up and running
Introduction to Drupal 7 - Getting Drupal up and runningIntroduction to Drupal 7 - Getting Drupal up and running
Introduction to Drupal 7 - Getting Drupal up and running
 
Business education
Business educationBusiness education
Business education
 
Drupal course-plovdiv-week1-day-1
Drupal course-plovdiv-week1-day-1Drupal course-plovdiv-week1-day-1
Drupal course-plovdiv-week1-day-1
 
Drupal-курс-лекция-6
Drupal-курс-лекция-6Drupal-курс-лекция-6
Drupal-курс-лекция-6
 
Курс по Drupal - лекция 3
Курс по Drupal - лекция 3Курс по Drupal - лекция 3
Курс по Drupal - лекция 3
 

Kürzlich hochgeladen

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

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

  • 1. Introduction to Drupal 7 Session 3.2 News section and home page block with Views Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
  • 2. Agenda • What is Views • Common uses • Administration overviews • Case study – making dynamic news section and latest news block for home page Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
  • 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 page Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
  • 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 doesn't 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. Views administration overview • Administration > Structure > Views • URL: admin/structure/views Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
  • 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 plus Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 6
  • 7. Creating latest news section, step 1 • Administration > Structure > Views > Add new view • URL: admin/structure/views/add Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
  • 8. Creating latest news section, step 2 Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 8
  • 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 button Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
  • 10. Creating latest news section, step 3 Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
  • 11. Format settings explained • Main format: table (easiest to use for beginners) • Title, date and body are grouped with <br/> in the end Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
  • 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. 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 top Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 13
  • 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 mainly Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
  • 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 theming Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15
  • 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. Your dynamic news section is ready Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 17
  • 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 news Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 18
  • 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 configurations Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 19
  • 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 settings Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 20
  • 21. Important: overriding values • Click on the a field where the override will be • Select the override from the drop-down Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 21
  • 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 option Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 22
  • 23. Tweaking the latest news block view Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 23
  • 24. Your home page news block is ready Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 24
  • 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. Recreate the feature and save it • Change the version to be up in some way Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 26
  • 27. Time for questions Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 27
  • 28. Contacts Kalin Chernev – E: kalata@shtrak.eu – T: twitter.com/kalinchernev – U: http://shtrak.eu/kalata Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 28