Adding a price to the menu item

Good Eatin' Goal: To add a field which will store the price of the menu item.

Additional modules needed: CCK (http://drupal.org/project/cck).

Basic steps

Now that we have created the Menu Item content type, we can set up the custom fields for our type based on the design we did earlier.

1. To create a new field, edit the Menu Item by clicking on the Edit link in the Content Type Manager.

Adding Products and Services_

2. Next, click on the Add field link. Drupal will then display a form where you can define the basics of the new field.

Edit Manage fields Display fields Add field |_

Menu Item

Create new field

Ttie machine-readable name of the field. This name cannot be changed laterf Ttie name will be prefixed with "fieldj and car indude lowercase unaccented letters, numbers, and underscores. Ttie length of the name, indudng the prefix, is limited to no more than 32 letters.

A human-readable name to be used as the label for this field In the Menu Item content type.

The type of data you would ike to store In the database with this field.

| Continue"]

3. For the price field, set the Field name to Price, the Label to Price, and the Field type to Decimal. Then click Continue.

4. After you click the Continue button, Drupal will prompt you for the Widget type that is used to edit the field. For the price field, the Text field is the most appropriate Widget.

5. Click Continue again, and Drupal will display a new form that contains some standard settings, as well as some settings that vary depending on the Field type you select.

6. For the price field, we will update the Help text and the Default Price as shown in the following screenshot:

These settings apply only to the Price field as it appears In the Menu Item content type.

The price of the dish or drink as it should appear on the menu. This should not be discounted for specials

_Chapter 3

7. There are also a number of values specific to the Decimal field type. These settings allow you to customize the allowable values and various formatting options. We will use the following values for our price field:

-Global settings-

These settings apply to the Price field In every content type in which it appears.

EZ1 Required

Number of values:

Seled a speaScnumber of values loi Ills Beld. or'Unllmlted'to provide an'Add more'button so the users can add as many values as they like.

Warning! Changing this setting after data has been created could result in the loss of datal Minimum:_

looo

Maximum:

150.00

Precision:

The total number of digits to store In the database, Including those to the right of the decimal

Scale:

The number of digits to the right of the decimal.

Decimal marker:

The character users will Input to mark the decimal point In forms.

Prefix:_

Define a string that should be prefixedto thevalue, like$or€. Leave blankfornone. Separate singular and plural values with a plpe{pound|pounds).

Suffix:

Define a string that should suffixed to the value, like m1 m/s=, kb/s. Leave blank for none. Separate singular and plural values with a pipe {poundlpounds).

+1 0

Post a comment