Jump to content

ICT:Drupal - creating new entities: content types

From Costa Sano MediaWiki

Step 1: Creating and configuring the content type

Initial creation of the content type

  1. structure/content types
  2. create a new content type
  3. give it a name - example chapter (NO s in the end)
  4. fill n the description
  5. REPLACE the proposed Title field label from Title to Code
  6. Fill in the Explanation or submission guidelines
  7. SAVE

Step 2: Create the fields for this content type

  1. create a new field and chose the field type
  2. give it a label like "Description", "Name", etc..
  3. depending on the field type - fill in what is needed for that field
  4. IMPORTANT: edit the machine name to for example ch_description, pl_name
  5. continue button
  6. continue specifying the field. Limited should be 1 for a simple field
  7. provide a help text or the user to explain what to fill in
  8. SAVE

Special Field for recursiveness: Parent

  1. create a parent field using reference as field type
  2. use content for the field type
  3. continue
  4. Type of reference: Content
  5. provide help text
  6. specify the content type -being the same for a recursive entity
  7. fill in the sort mode: normally Code - with the sort direction
  8. SAVE

All field defined ?

Check the list of all fields for

  1. given names and tyoes
  2. SPECIAL check for the systems name: should be field_xx_fieldname
  3. xx = the first 2 characters of the content type

Form Display arrangement

Goto the tabFom Display

  1. disable all the unneeded system field: replace content by disabled
  2. for the parent field - replace autocomplete by "select list"
  3. check that you only have the fields you want
  4. SAVE

Step 2 creating and configuring the view =

creating the view

  1. structure/views
  2. create new view
  3. give it a name: the samename of the entity but this time WITH s at the end
  4. give it a description
  5. show Content of type "table name"
  6. select Create page and give it a title - example Chapters with s
  7. modify the path: add admin/ in front of the page name
  8. select Page display settings: Table of fields
  9. items to display - 10 is OK with use pager
  10. NO menu link of RSS feed nor a block creation - it will be a dashboard page
  11. Save and edit

Edit the view

  1. there should be an initial field with name Title.
  2. select this and replace the name/label Title by Code
  3. deselect link to the content
  4. style settings: check that the default class is enabled
  5. APPLY
  6. add supplementary fields from the entity/content type
  7. add a special field: "Link to edit Content" from category content
  8. no label for this field
  9. replace "edit" by a pencil and go to Table/Settings and select Right align for this field
  10. rearrange the list of fields and put the Link to edit Content as first column
  11. rearrange can be found under Add - select 0 for the link and APPLY
  1. in Header selext Add
  2. select Text Area in Global
  3. select Display even if view has no result
  4. in content past this and adapt chapter (conten type name) and chepters (view name) and APPLY
<a href="/node/add/chapter?destination=/admin/chapters">Add a Chapter</a>

Sorting and Filtering

  1. goto the sorting section
  2. add Title (content) ascending and delete all the rest
  3. filter only on the table and delete all the rest.

STEP 3: Testing

  1. use /admin/viewname with for example viewbame = chapters then admin/chapters
  2. first time you should see the title of the view and only a link to create a first record
  3. create a first record
  4. check with the pencil if one can edit the record - not going to SOLO but staying in GIN
  5. make a sublevel record and check the parent field
  6. if other foreign keys are present, check

Document revision 1 - 20260305