22
Drupal 7 beginner tutorial Contents, content types, fields and views Cedric Chaux , Chris

[DCTPE2011] Drupal 7 的Fields/Views 運用

Embed Size (px)

Citation preview

Drupal 7 beginner tutorialContents, content types,

fields and views

Cedric Chaux , Chris

What do you need ?

Drupal 7 basic installation including Field , and Field UI module ( enabled by default to the core )

Drupal module : Views ( Views_ui need to be enabled )

dependencies module : Ctools

Where to get them ? 

http://drupal.org/project/drupal

http://drupal.org/project/views

http://drupal.org/project/ctools

Practice website.

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.

     URL : http:// …     login :      password : 

Are you ready ?

Introduction 

Drupal is a CMS : Content management system.You have to let Drupal know how to use your content and it will do the work for you.

Why Drupal 7 ?Someday you'll have to learn it.

Is it ok to use ?It's a pretty recent but stable release. It recently have been updated to correct a security issue.

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.

Drupal contents are nodes. node is like atom for matter.

Why to start with content ? not menu , blocks , or users ?Everything in Drupal is about content.

What do you need to know about contents ?        

As a Drupal user, this is the first basic thing you will need to do :

Manage your content

AddEdit

DeletePublish.

Nodes and contents 

Basic information structure.

All contents have a title. This is not a field. It has many different usage. 

Basic content have a field : the body ! 

Display content : Teaser of content or full view ? Why does it matter ?

Text format : Plain text , simple HTML or full HTML code ? 

Content settings

Menu Where to display the content in the menu. RevisionManage and keep the different versions of your node.urlChoose the for the page of your content , basic url use node/[id]Commentlet other users add comments to your contentAuthoringWho created the content and when ? PublishIs the content available on the website ?

Why do you need Content type ?

Content types are like templates for contents.Think of Letter templates on your favorite word processor.Would you like to type 100 times the same information when you only need to enter your name ?

Manage the content types : a more advance task

Add information > Fields

Settings and Display

Organize > View

Basic content type

Page

Article ( called story in Drupal 6 )

most simple Content type :

• life cycle ( Published / Unpublished )

Only one field.

Advanced type of content in Drupal    Comment content typeFor static content , no need to be modified. Comes from node module directly. Blog entryTime sensitive content ( updates , news , post ).

Book pagehierarchically organized content ( index , help , documentation , guide )

Forum topicAvailable when enabling forum module. Integrated to forum module functionalities PollAvailable when poll module is enabled. Description of a poll. Integrated to poll module.

Content type settings

Similar to content settings : However content type settings will apply to every content that will be created with this content type.

Warning ! Some of the setting cannot be changed on individual nodes.

Basic content types are not enough.

Why would I need more special content  when I can create anything with a simple page ?

Other people will add content too.

I want the content to contain specific information.

I want to do something special with my content.

Example : Biography

What do I need ?

People must provide a picture.

I need to know something specific about their diploma and their specialty.

Biography content type

Then what should I do ?

Create a new content type.When adding a biography I will choose this content type.

How to add more information to my content type ?Create new fields corresponded to the information you want

to add.

What is a field ?Additional specific type of information attached to content

type.

Choice of field

File ( any )

Image ( large , medium , thumbnail ) 

Boolean 0 1

Decimal

Float  1.1111231213

Integer 1 2 3 ... 

List ( Create your own ) 

Long text

Long text + summary ( like body )

Taxonomy ( associated to tag ).

How to adds content with fields ?    

A widget let you decide how users are going to enter the data when adding new field. You can choose the most suitable widget.

Each fields type has its own widgets.

Let's create a content type !    

Biography 

We will need 

Your name ( title )

Body ( your resume )

A Picture

Your diploma ( list )

Your specialty ( tag )

Do not save your content type, we only need one content type.

Let's create a biography content

Each of you will now create their own biography using the Drupal content menu.

We will use these contents in order to create a very simple view.

View    

Now we have a lot of biographies. 

Thanks to view , users will be able to navigate through all these contents.

A view is basically a page that allow you to display a list of content. It's an overview of contents.

In views , content fields become extremely useful since it allows you to play around with your information.

You get to decide what do display and how to display it.

Since you have a lot of possibilities to display content , there are many many views parameters. Don't be scared ! 

Do we need a view for biographies ?

We do have many biographies now on our website.

Putting all of them on a menu would be messy...

We do not want biographies to appear on the front page

Therefore we need a view to display our biographies.

We will need to Give a name to the view

Decide how the view will be shown ( format )

Decide which fields we want to show.

Tell the view what type of content we want to see ( filter )

Tell the view how to arrange the content ( sort )

User mistakes ...

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.

Some of you might have wrote Surname / First name or Family Name / First name , or even only your First name in the content title.

We decide the title , is the main description of the user.

We are going to create two new fields : First name , Last name as text in the content type. 

We are also going to change the label for title , so it reflect the meaning : Activity Description.

Updating the view        

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.

We will add two fields : "Family name" and "First name" to the view and place them after the picture.

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

Thank you !

You should have a lot of questions to ask now ...