[DCTPE2011] Drupal 7 的Fields/Views 運用


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

[DCTPE2011] Drupal 7 的Fields/Views 運用

  1. 1. Drupal 7 beginner tutorial Contents, content types, fields and views Cedric Chaux , Chris
  2. 2. What do you need ? <ul><ul><li>Drupal 7 basic installation including Field , and Field UI module ( enabled by default to the core ) </li></ul></ul><ul><ul><li>Drupal module : Views ( Views_ui need to be enabled ) </li></ul></ul><ul><ul><li>dependencies module : Ctools </li></ul></ul><ul><ul><li>Where to get them ?  </li></ul></ul><ul><ul><li>http://drupal.org/project/drupal </li></ul></ul><ul><ul><li>http://drupal.org/project/views </li></ul></ul><ul><ul><li>http://drupal.org/project/ctools </li></ul></ul>
  3. 3. Practice website. <ul><li>In order to follow this tutorial it would be better if you could connect to the Drupal 7 website I created for the demo  using your laptop. </li></ul><ul><li>      URL : http:// … </li></ul><ul><li>      login :  </li></ul><ul><li>      password :  </li></ul><ul><li>Are you ready ? </li></ul>
  4. 4. Introduction  <ul><li>Drupal is a C MS : Content management system. </li></ul><ul><li>You have to let Drupal know how to use your content and it will do the work for you. </li></ul><ul><li>Why Drupal 7 ? </li></ul><ul><li>Someday you'll have to learn it. </li></ul><ul><li>Is it ok to use ? </li></ul><ul><li>It's a pretty recent but stable release. It recently have been updated to correct a security issue. </li></ul><ul><li>Mistakes I made when I learning Drupal ( 6 ): I didn't try to understand content type. Result : Always tried the hardest , most unstable solution : There are often many ways to do the same things in Drupal. </li></ul><ul><li>Drupal contents are nodes . node is like atom for matter. </li></ul><ul><li>Why to start with content ? not menu , blocks , or users ? </li></ul><ul><ul><li>Everything in Drupal is about content. </li></ul></ul>
  5. 5. What do you need to know about contents ?         <ul><li>As a Drupal user, this is the first basic thing you will need to do : </li></ul><ul><li>Manage your content </li></ul><ul><li>Add </li></ul><ul><li>Edit </li></ul><ul><li>Delete </li></ul><ul><li>Publish. </li></ul>
  6. 6. Nodes and contents  <ul><li>Basic information structure. </li></ul><ul><li>All contents have a title . This is not a field. It has many different usage.  </li></ul><ul><li>Basic content have a field : the body !  </li></ul><ul><ul><li>Display content : Teaser of content or full view ? Why does it matter ? </li></ul></ul><ul><ul><li>Text format : Plain text , simple HTML or full HTML code ?  </li></ul></ul>
  7. 7. Content settings <ul><li>Menu   </li></ul><ul><li>Where to display the content in the menu.  </li></ul><ul><li>Revision </li></ul><ul><li>Manage and keep the different versions of your node. </li></ul><ul><li>url </li></ul><ul><li>Choose the for the page of your content , basic url use node/[id] </li></ul><ul><li>Comment </li></ul><ul><li>let other users add comments to your content </li></ul><ul><li>Authoring </li></ul><ul><li>Who created the content and when ?  </li></ul><ul><li>Publish </li></ul><ul><li>Is the content available on the website ? </li></ul>
  8. 8. Why do you need Content type ? <ul><li>Content types are like templates for contents. </li></ul><ul><li>Think of Letter templates on your favorite word processor. </li></ul><ul><li>Would you like to type 100 times the same information when you only need to enter your name ? </li></ul><ul><li>Manage the content types : a more advance task </li></ul><ul><ul><li>Add information > Fields </li></ul></ul><ul><ul><li>Settings and Display </li></ul></ul><ul><ul><li>Organize > View </li></ul></ul>
  9. 9. Basic content type <ul><li>Page </li></ul><ul><li>Article ( called story in Drupal 6 ) </li></ul><ul><ul><li>most simple Content type : </li></ul></ul><ul><ul><ul><li>life cycle ( Published / Unpublished ) </li></ul></ul></ul><ul><ul><ul><li>Only one field. </li></ul></ul></ul>
  10. 10. Advanced type of content in Drupal     <ul><li>Comment content type </li></ul><ul><li>For static content , no need to be modified. Comes from node module directly. </li></ul><ul><li>  </li></ul><ul><li>Blog entry </li></ul><ul><li>Time sensitive content ( updates , news , post ). </li></ul><ul><li>Book page </li></ul><ul><li>hierarchically organized content ( index , help , documentation , guide ) </li></ul><ul><li>Forum topic </li></ul><ul><li>Available when enabling forum module. Integrated to forum module functionalities </li></ul><ul><li>  </li></ul><ul><li>Poll </li></ul><ul><li>Available when poll module is enabled. Description of a poll. Integrated to poll module. </li></ul>
  11. 11. Content type settings <ul><li>Similar to content settings : However content type settings will apply to every content that will be created with this content type. </li></ul><ul><li>Warning ! Some of the setting cannot be changed on individual nodes. </li></ul>
  12. 12. Basic content types are not enough. <ul><li>Why would I need more special content  when I can create anything with a simple page ? </li></ul><ul><ul><li>Other people will add content too. </li></ul></ul><ul><ul><li>I want the content to contain specific information. </li></ul></ul><ul><ul><li>I want to do something special with my content. </li></ul></ul><ul><li>Example : Biography </li></ul><ul><ul><li>What do I need ? </li></ul></ul><ul><ul><li>People must provide a picture. </li></ul></ul><ul><ul><li>I need to know something specific about their diploma and their specialty. </li></ul></ul>
  13. 13. Biography content type <ul><li>Then what should I do ? </li></ul><ul><li>Create a new content type. </li></ul><ul><ul><li>When adding a biography I will choose this content type . </li></ul></ul><ul><li>How to add more information to my content type ? </li></ul><ul><ul><li>Create new fields corresponded to the information you want to add. </li></ul></ul><ul><li>What is a field ? </li></ul><ul><ul><li>Additional specific type of information attached to content type. </li></ul></ul>
  14. 14. Choice of field <ul><ul><li>File ( any ) </li></ul></ul><ul><ul><li>Image ( large , medium , thumbnail )  </li></ul></ul><ul><ul><li>Boolean 0 1 </li></ul></ul><ul><ul><li>Decimal </li></ul></ul><ul><ul><li>Float  1.1111231213 </li></ul></ul><ul><ul><li>Integer 1 2 3 ...  </li></ul></ul><ul><ul><li>List ( Create your own )  </li></ul></ul><ul><ul><li>Long text </li></ul></ul><ul><ul><li>Long text + summary ( like body ) </li></ul></ul><ul><ul><li>Taxonomy ( associated to tag ). </li></ul></ul>
  15. 15. How to adds content with fields ?     <ul><li>A widget let you decide how users are going to enter the data when adding new field. You can choose the most suitable widget. </li></ul><ul><li>Each fields type has its own widgets. </li></ul>
  16. 16. Let's create a content type !     <ul><li>Biography   </li></ul><ul><ul><li>We will need  </li></ul></ul><ul><ul><li>Your name ( title ) </li></ul></ul><ul><ul><li>Body ( your resume ) </li></ul></ul><ul><ul><li>A Picture </li></ul></ul><ul><ul><li>Your diploma ( list ) </li></ul></ul><ul><ul><li>Your specialty ( tag ) </li></ul></ul><ul><li>Do not save your content type, we only need one content type. </li></ul>
  17. 17. Let's create a biography content <ul><li>Each of you will now create their own biography using the Drupal content menu. </li></ul><ul><li>We will use these contents in order to create a very simple view. </li></ul>
  18. 18. View     <ul><li>Now we have a lot of biographies.  </li></ul><ul><li>Thanks to view , users will be able to navigate through all these contents. </li></ul><ul><li>A view is basically a page that allow you to display a list of content. It's an overview of contents. </li></ul><ul><li>In views , content fields become extremely useful since it allows you to play around with your information. </li></ul><ul><li>You get to decide what do display and how to display it. </li></ul><ul><li>Since you have a lot of possibilities to display content , there are many many views parameters. Don't be scared !  </li></ul>
  19. 19. Do we need a view for biographies ? <ul><li>We do have many biographies now on our website. </li></ul><ul><li>Putting all of them on a menu would be messy... </li></ul><ul><li>We do not want biographies to appear on the front page </li></ul><ul><li>Therefore we need a view to display our biographies. </li></ul><ul><li>We will need to  </li></ul><ul><ul><li>Give a name to the view </li></ul></ul><ul><ul><li>Decide how the view will be shown ( format ) </li></ul></ul><ul><ul><li>Decide which fields we want to show. </li></ul></ul><ul><ul><li>Tell the view what type of content we want to see ( filter ) </li></ul></ul><ul><ul><li>Tell the view how to arrange the content ( sort ) </li></ul></ul>
  20. 20. User mistakes ... <ul><li>If I want to sort the view by surname , how to I know from the title which part of the title field is the name. </li></ul><ul><li>Some of you might have wrote Surname / First name or Family Name / First name , or even only your First name in the content title. </li></ul><ul><li>We decide the title , is the main description of the user. </li></ul><ul><li>We are going to create two new fields : First name , Last name as text in the content type.  </li></ul><ul><li>We are also going to change the label for title , so it reflect the meaning : Activity Description. </li></ul>
  21. 21. Updating the view         <ul><li>Now that we have updated our content. We need to change the  view to insert the new fields and use them to sort our content. </li></ul><ul><li>We will add two fields : &quot;Family name&quot; and &quot;First name&quot; to the view and place them after the picture. </li></ul><ul><li>Now create a clone of bio view , and have fun with it using the update preview button if there is enough time left. Try to sort the view by content </li></ul>
  22. 22. Thank you ! <ul><li>You should have a lot of questions to ask now ... </li></ul>