Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Introduction to Drupal 7 - Content types and fields

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige

Hier ansehen

1 von 24 Anzeige

Weitere Verwandte Inhalte

Ähnlich wie Introduction to Drupal 7 - Content types and fields (20)

Weitere von Kalin Chernev (17)

Anzeige

Aktuellste (20)

Introduction to Drupal 7 - Content types and fields

  1. 1. Introduction to Drupal 7 Session 2.2 Content types and fields Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 1
  2. 2. Agenda • What is a content type • Content type settings • Fields • Popular contributed modules Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 2
  3. 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 them Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 3
  4. 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 enabled Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 4
  5. 5. Creating new content type • Administration > Structure > Content types • URL: ../admin/structure/types Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 5
  6. 6. Adding news content type example Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 6
  7. 7. Fields management • Administration > Structure > Content types • {The content type} > manage fields Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 7
  8. 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. 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 calendar Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 9
  10. 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 now Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 10
  11. 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 value Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 11
  12. 12. Adding the date field Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 12
  13. 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. 14. Adding an image field Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 14
  15. 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 one Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 15
  16. 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 settings Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 16
  17. 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. 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 version Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 18
  19. 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 it Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 19
  20. 20. News content type feature Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 20
  21. 21. Enabling the News content type • Administration > Structure > Features Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 21
  22. 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 users Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 22
  23. 23. Time for questions Drupalist: Kalin Chernev Course by Init Lab (http://initlab.org) 23
  24. 24. 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) 24

×