Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now we are going to expand the kinds of data we can put into our Drupal site by turning on some extra modules. We'll use one module that comes with CCK but we'll also need to download and install another one and we'll briefly mention a third. We'll put a slide with all the web addresses you will need at the end. And as always if you have trouble installing modules, see the video in lynda.com's Drupal Essential Training course, "Expanding your Site's Capabilities with Modules." You might remember that when we first installed and enabled CCK, the only field type we made available was called text. Now let's turn on the other field type that comes with CCK, Number. To do so go to Administer > Site building, and Modules. You will see the CCK group right near the top, go down, select Number, then down to the end of the page and click Save configuration.
Let's take a quick look at what at we get by turning on that Number module. So we don't affect any of our other work, this will just be a temporary content type that we'll create and we'll throw it away later. To do so we go to Administer > Content management > Content types. Add a new content type and as we did in another video, we'll call this Temp. Scroll to the bottom and save that content type. In that temp content type, go to Manage fields and as before you can add new fields.
Let's add a new field, we'll just call and Number field and the field will be called number_field. Then when we go to our Select a field type, we now have several additional choices. Three of these have to do with numbers. Decimal and Float both allow for you to have number such as 5.6. They have technical differences, which have to do with mathematics, and if you don't know the difference then Decimal should be just fine for you. Integer allows only whole numbers, 1, 2, 3, -5, and so forth. Let's make ours Decimal for now. And in our form element, we'll keep it as a text field. That makes the most sense for something that's a number value. Scroll to the bottom and Save.
Drupal as with most computer systems handles number information a little bit differently from text information and that's because it is basically different information. Text strings don't really have a value. They have a sort of lexical meaning but not a value in the sense that one is bigger than the other. Number fields however do have a value and if you scroll down, you will see some options that let you control that value. For example, you can set a Minimum and Maximum. If someone were to enter a number that's bigger or smaller than you specified, Drupal would just kick it out.
They wouldn't let them save that node that they created. You can also set the Precision and the Scale. That has to do with the total number of digits in a decimal number, and you can read the Help text on that if you need any help for it. You can also change what the Decimal Marker is, should it be a point as it is in the United States, or a comma as it is in some European countries and so forth. Finally, you can add a Prefix or Suffix. That's very useful for number values because it allows you to do such things as create dollar amounts. You could have a prefix of the dollar sign and allow only two digits after the decimal point, so $3.52 but not $3.529. We'll just save the fields as it is now.
As always if we want to see exactly how this works, we'll create a content node of that content type Temp, and as we scroll down we see there is our Number field.
Get unlimited access to all courses for just $25/month.Become a member
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.