Your SlideShare is downloading. ×
Introduction to Drupal 7 - Content types and fields
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Introduction to Drupal 7 - Content types and fields

2,639
views

Published on

This is the second session presentation of the second lecture. It's on content types and fields, and how to save the work in features.

This is the second session presentation of the second lecture. It's on content types and fields, and how to save the work in features.

Published in: Technology

2 Comments
2 Likes
Statistics
Notes
No Downloads
Views
Total Views
2,639
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
2
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Drupal 7 Session 2.2 Content types and fieldsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
  • 2. Agenda• What is a content type• Content type settings• Fields• Popular contributed modulesDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
  • 3. What is a content type• Simply: the most powerful Drupal feature• By default: 2 content types: – Basic page – Article• Unlimited number of custom content types• Many types of fields, no limitations on the number of themDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
  • 4. Content type settings• Name and description fields• Submission form settings• Publishing options• Display settings for meta data• Comments settings• Menu settings• Other – when additional modules are enabledDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 4
  • 5. Creating new content type• Administration > Structure > Content types• URL: ../admin/structure/typesDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
  • 6. Adding news content type exampleDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 6
  • 7. Fields management• Administration > Structure > Content types• {The content type} > manage fieldsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
  • 8. Manage Fields vs Manage Displays• Manage fields – Adding new fields – Removing fields – Grouping fields (with additional module)• Order of the fields• Setting labels display• Setting fields contents display• Again, grouping fields in groups (with additional module)Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 8
  • 9. Adding a date field to news• Download/Install Date module• Enable “Date”, “Date API” and “Date Popup”• Go to admin/structure/types/manage/news/fields• Add a new field: – Label: Original publish date – Field type: Date – Machine readable: “orig_pub_date” – Widget type: Pop-up calendarDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
  • 10. The date field• Field settings: – Date attributes to collect: leave it as it is, the granularity is good to be by minutes – Collect an end date: leave it as it is, we don’t need to collect end date value – Time zone handling: set to “No time zone conversion” – Cache dates: leave it as it is, we don’t need caching for nowDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
  • 11. Advanced date field settings• Required field: yes, we want to make sure the user has filled in a value here• Date entry options: set it as you prefer the format to be• Starting year: -0 years from now: we don’t really need more time back• Ending year: +0 years from now: we don’t need more time ahead as well• Default date: set it to “Now” as we want the field to take current time by default• Number of values: set it to “1”, as we need only 1 valueDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
  • 12. Adding the date fieldDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 12
  • 13. System date settings Reports will notify you for required date settings. Some recommended options:Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 13
  • 14. Adding an image fieldDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
  • 15. Image field settings• Allowed file extensions: the extensions the user can upload in the field: jpg, png, etc• File directory: used rarely, only if you want the field to store images in specific folder which is not the sites/default/files folder• Maximum and minimum image resolutions: used rarely, only if you want to limit the input dimensions of the images• Maximum upload size: this is the limitation you can set on the physical size of the files• Enabling Alt and Title: good to have if the administrator/editor has some SEO knowledge to populate these meta data• Preview image style: options come from Image style module. The size you specify here is only for the back-end work of the admin• Number of values: from 1 to unlimited, depending on the case• Default image: rarely used, only if a feature or section requires an image, you can set one default to be displayed when the admin does not upload oneDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15
  • 16. Adding tags field• You can use the default existing Tags vocabulary field• Use the ”Autocomplete term widget (tagging)” widget type• Save and create with default settingsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 16
  • 17. Adding tags field• You can either use and existing Category vocabulary field or create one (if the first one is not available) (1st screenshot)• Use the ”Select list” widget type as you want the Category field to be a list of values, only 1 of which can be selected• Set the number of values to be 1, in the Category field settings (second screenshot)Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 17
  • 18. Compiling news content type feature• We can export our News content type configurations into code for better versioning• Make sure you have the Features module enabled and go to Administer > Structure > Features > Create new• Name and description of the feature are arbitrary – anyway aim to specify them logically enough you can remind yourself what the feature is about• You can start with 7.x-1.0 for the versionDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 18
  • 19. News content type feature• Select “News” content type from the node bundle components options• Select all fields related to the news content type from the Fields component: all that start with “node-news-…”• Download the feature• Place the feature in your modules directory and enable itDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 19
  • 20. News content type featureDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 20
  • 21. Enabling the News content type• Administration > Structure > FeaturesDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 21
  • 22. Popular contributed modules• Date – for date type fields• Field Group – grouping multiple fields in a fieldset with various options of output• Link – having options for attributes• Email – including validations• Field permissions – for settings permissions on a field-by field level• Media – different media handling• References – referencing nodes and usersDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 22
  • 23. Time for questionsDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 23
  • 24. ContactsKalin Chernev – E: kalata@shtrak.eu – T: twitter.com/kalinchernev – U: http://shtrak.eu/kalataDrupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 24