What is Reference Field in Drupal Content Type

Drupal system has several options to save different types of information. Drupal allows to create content type which is collection of different fields to save information. Information can be student profile, examination result, employee salary, employee leave details etc. Some of the fields in content type are basic fields like text field, number fields etc. The reference fields is also a type of field available in content type which refer to other content or user or taxonomy. It means that the information for that filed is already inserted into the system and available with some other content or user or taxonomy. You just refer that field in your content type and link that field in your content type.

drupal reference field

Lets see some examples which will help in understanding concept of reference field better.

  1. Take example of a school where all the details of students is entered into system. Each student is represents by a unique student ID in database. Now another information of result of each student need to inserted into system so create a content type of exam result. Each result relates to one of the student therefore a reference field need to be created into this “result” content type. This reference field will use “student ID” from “student profile” data. In this way results are referenced to students and a relationship is established.
  2. Assume a case of a organisation where employee details are fed into a database. Each employee is represented by a unique employee ID. There are some other details like employee salary and employee leave which need to be inserted into system so create a new content type for salary and leaves. Each of these content type will use a reference field from employee to get employee ID. This way each salary and leave is linked to concerned employee.

So reference field link information between two content type. You can take it like creating a table relationship. Whenever we create a database with multiple table, relationship between tables is also need to be created. Same thing applies to Drupal. Reference field allows you to create relationships.

How to create a new Content Type in Drupal

In my previous Drupal article, I tried to explain the Content Type in Drupal. In general, Content Type is a group of fields to create a specific form for entering the specific type of information into the Drupal system. Content Type allows user to enter different types of information in Drupal.

content type in drupal

Creating a new Content Type is not difficult but you should have understanding of different types of form fields available in Drupal. I will go into more details about different types of form fields in next article but at this time lets discuss about process of content type creation.Key steps for new Content Type in Drupal are:

Create New Content Type in Drupal

  • After login into Drupal, go to structure section and then Content Types. This is the place to create and manage fields,forms and display settings of your content
  • Now go to +Add content type
  • Now give a unique name to your new content type
  • Content type is a group of form fields for saving specific type of information into database and displaying same thing for users. So you need to enter form submission settings like Title field name, preview before submission. Title is a essential field in all content type.Similarly you can check publishing and display settings of this content type. You can select a particular menu to display this content type. Now save these settings and proceed.
  • Your content type is created with one default Text field named body. You can keep this or remove if you dont require. In this new page you will see four tabs.
    • Edit – To edit content type settings which we just created
    • Manage Fields – To add, edit, delete or change settings of form fields
    • Manage form display – To manage the display of form for this content type. All the included fields have specific display settings. You can hide a form field also.
    • Manage display – You can change the display property of field label. When you see your saved content, labels can be displayed above or inline with the field data.
  • Now you can add more fields in your content type.Go to Manage fields tab and click on +Add field.
  • You will see list of available field in the Add a new field option. Fields are broadly categorized in four type
    1. General – General fields like Boolean, date , email etc. You can also add comments as a field.
    2. Numbers – Number field like integer, float etc
    3. Text – Text fields like plain text, long text etc
    4. Reference – Reference fields are fields available in other content, taxonomy, user or other Drupal system. This is most useful way to create relationship between different parts of the system. You can link a field of other part of system and create a relationship. Just see this examples of reference field
      • ABCD is a school having profile data of all student. Each student has a unique ID. School display the result of student online. so there is one Content type “student result”. While entering result of each student, you can reference student name from the Student profile content. When you enter result, this referenced field will show the list of students.In this way the information is interlinked and a proper relationship is created.
      • In the above example, if Student unique record is saved as user, then reference field can be selected from user.
      • If result is entered into system by concerned class teacher and we expect to display display student attached in that particular class, then we may use reference user profile and get filtered class students through the view.
      • If you want that names of the city should be unique and you saved them as Taxonomy term then you can reference this Taxonomy term in user location, address etc.

I hope you would have got a general idea of creating a new content type in Drupal. Creating a new content type with general fields, number or text fields is easy. But real world examples require relationships between different information in the system so you need to create reference field. Use of reference field is quite vast which i would like to discuss in detail in next articles.

What is Content Type in Drupal 8

Users who are new to Drupal system may get little confused for the term Content Type. Drupal 8 is highly flexible CMS where user can create content more than just a article. Most of the CMS allows to create a fixed type of content. For example WordPress allows to create post or page type of content. When you create a post in WordPress, the form has few input fields like title, description, tag etc. So the form fields are fixed for post in WordPress. We can say that WordPress allows to store information in only one particular fashion.

Drupal 8 content type

If user want to store information about a electronic product then desired fields in form may be product title, product price, product specification, product description, product rating etc.  CMS like WordPress or Joomla has no provision to input product details in independent form fields.

Let’s take example of different cases. When you fill up form for some examination then input fields in form are specific. Similarly when you fill up form for ticket booking then input fields in form are also specific. There are lot of different types of forms which collect information from user. If we apply same concept to Content Management System(CMS) then CMS also use form to collect information. This collected information from the form is saved into database and later it is retrieved for displaying to the end users.

So it is the input form which allows CMS to collect different type of information. Some CMS like WordPress has one particular type of form which is typically used for article type of data input. WordPress like system are not user-firledly for storing specific type of content. But Drupal has solution for specific type of content also. Drupal allows to create forms for different types of content.Drupal allows to create customised forms for different type of content. If you want to collect information about student profile then you can create a form with specific fields like student name, class, date of birth, school name, home address etc. If you want to collect information about examinination result then you can create fields like roll no, marks obtained  etc. If you want to collect information about taxi hiring services in city then you can have fields like taxi no, owner name, rates for 80 km, rates for 120 km, night charges etc.

You would have understood that Drupal allows to create form with different types of fields. Drupal is quite flexible for creating different types of form for content.Each of these form represents a particular content. Different form represent different Content Type in Drupal 8.

The above discussion is  primarily meant to convey the meaning of term Content Type in Drupal 8. How a content type is created and how it is used to input content is also need to be understood.

User can create a particular Content Type from the Structure section in Drupal 8 Admin panel. Give a name to this new Content type and then add fields in this Content type. Now this particular Content Type in Drupal 8 becomes a bundle of fields to store specific information.

For inputing information in this specific Content Type, you need to access it from the Content section of Drupal 8 admin panel. If administrator gives access to this Content Type from some other menu then you can access it from other menu item also. But Administrator has access to all content types from Content section for content generation. You select your content type and then insert information in each of the field for saving it into database.

How to build website with Drupal 8 – Content

This is in continuation to my earlier articles about Drupal 8 wherein Drupal 8 configuration, Drupal 8 Extension, Drupal 8 Appearance and Drupal 8 User management has been discussed. Now two important things for Drupal 8 website development i.e Drupal 8 Content and Drupal 8 Structure need to be understood. As the name suggest Drupal Structure section gives lot of options for website design. We will discuss Drupal 8 Structure in next article. In this article I just like to discuss Drupal 8 Content.

Drupal 8 content

What is Drupal 8 Content

All CMS gives us platform to store content in database and publish the same on webpage for end users. Content can be an article, employee details, equipment details, product details or other information which need to be stored in database.

As we know that digital information is saved in database through the webform. Each form has multiple fields and those fields allows to input specific information about the content. Lets take example of content which stores details of product. In this specific product detail content , there is lot of information about the product like product name, price, discount, seller, rating, specifications, description etc. In this case you need a form to store all these information about the product. The form will have fields for inputting all these information.So the group of these fields for specific content creates a bundle of fields. The bundle of fields is created for a specific type of information. A particular bundle represents a specific group of field, means a specific content type. Therefore a content type is group of fields for inputting specific information.

Content types are created from the Drupal 8 Structure section because it is part of website design.

For storing information into any content type, you need to enter into Drupal 8 Content section. The Content section is accessible from the primary menu for administrators. The Content section shows list of content types which you earlier created in the structure section. Select any content type for inputting information, you will see number of form inputs where you can insert inputs and then save the information in the database.

Website administrator has rights for all the action that’s why he can see all the content types. Create content, edit content, delete content, edit own are different actions associated with content. Permission for each of these action for each of content type can be given to particular role by the administrator.We earlier discussed User permissions and roles in Drupal 8 user management. Users who are not authorized will not be able to create, edit or delete content. So you can delegate authorities to groups for different tasks for each of content type.

Broadly we can say that Content section is the gateway where you can access different Content Types for inserting information into CMS. On the other hand Content Types in Structure section is the place which allows you to create a specific Content Type.

How to build website with Drupal 8 – Extend

When you install Drupal 8, you first look at the primary menu . Each menu item provide link for specific administrative zone. One of the primary link is Extend. The meaning of term Extend itself convey the role of this section. The Extend section allows you to extend the Drupal 8 system .

Drupal 8 Extend

In my first article about Drupal 8 introduction , I just talked about the modular approach of Drupal 8 CMS. The Drupal 8 has a core system which control the basic functionality of a web system. The core system is designed in such a way that it allows you to add other application packages into Drupal 8 system.

Why you need additional software packages in Drupal 8 system

Drupal 8 standard package come along with core application and some added apps called modules. This default system provides certain facilities to users.If user want some facility which is not available in default system then user can add a module into Drupal 8 system. For example, you can add Google Analytics module for monitoring website traffic. Similarly you can add Webform module for creating forms and surveys for users.

Where can you get modules for Drupal 8

Drupal website has a repository for core, themes, modules and distributions. The Download & Extend link in Drupal website list all these added packages for Drupal. You can access and search for your required feature. There are thousand of Drupal modules which extend the horizon of Drupal 8 system.

The Extend section can be accessed from the primary menu. This section basically deals with adding/removing and updating modules. This section is divided in three tabs i.e List, Update and Uninstall

List

This List tab in Drupal 8 Extend section shows the list of installed modules in your Drupal 8 system. You can see that there are several modules which are installed along with standard Drupal 8 package. The standard Drupal 8 system which we see after installtion is the result of several core modules. Core modules View, Taxonomy, Node, Field , File etc provide several features in Drupal 8 system. User has option to install new module. You can download compressed file package of particular module and then upload it into your drupal system for installation. Alternatively you can directly install from the package url.

Update

This Update tab in Drupal 8 Extend section provides information on available updates for the installed modules.

Uninstall

This Uninstall tab in Drupal 8 Extend section allow to uninstall module from the Drupal 8 system. Drupal has a system of module development where modules depend on other modules as well. If other module is dependent on a particular module X then this restrict uninstall of this X module.

Overall Drupal 8 Extend option gives a user friendly interface for module installation, uninstall and update. It becomes very easy to add,remove or update module from this interface ,otherwise doing same thing as a developer could have been very difficult for users.

How to build website with Drupal 8 – Website Appearance

Website appearance is one of the important aspect of website design.Storing content into database, content retrieval from the database and presentation of content over standard templates are key functions of a CMS. The outer presentation layer picks the content and displays it in a systematic manner. Drupal themes are part of outer presentation layer and themes are the main element which govern the Drupal 8 website appearance.

Drupal 8 website appearance

Each webpage can be divided into multiple parts like main content area,header, footer,sidebar and other smaller sections. Theme designer creates different parts in the theme template and website administrator puts different information in each of these parts. For example You can place blocks in header, sidebar etc. If you place login block in header then it will be visible in header.If you place it in sidebar then it will appear in sidebar.

Broadly Drupal 8 website appearance includes install/uninstall of theme, updates of theme and settings for each of the theme. Drupal 8 website appearance section can be accessed from the primary menu. There are three tabs in this section i.e List,Updates and Settings.

List

This section shows the list of themes installed in Drupal 8. There is provision to install new themes. You can give url of theme package or upload the package for installation into your Drupal 8 system. After installation , new theme will be visible in the list of available themes. If you want to use one particular theme for your website then you need to set it as default.

Update

This section provides information on the available updates for these installed items. Drupal 8 system automatically checks for available updates but there is option to check updates manually.

Settings

There are few Global settings for the themes like Logo image. favicon etc. These are applicable to all the themes.You can select link of any theme here to access settings of particular theme. This is the main area where you can change color scheme of theme and change other theme parameters.Each theme developer provides set of parameters which theme user can configure for specific appearance. User can configure color for fonts, borders,background text etc. These setting allows you to change Drupal 8 website appearance as per user specific requirement.

I hope this broader idea of Drupal 8 website appearance will help you in understanding the Drupal system.

How to create website with Drupal 8 – User management

User management is one of important aspect of any web system. You can access the Drupal 8 user management from the People section. People section has three tabs i.e List, Permissions and Roles. Look at following points to see how Drupal 8 User management works.

Drupal 8 user management

Drupal 8 user management

  • Administrator has default right to create user from the administrator interface. Administrator can add user, delete user, block user, unblock user or change other user settings.
  • Each website has certain content which is visible to everyone, means anonymous users can see the content. Some of the content may be for certain authorized users, meant for registered users. So you can control the access to some content by setting the view authority. Similarly other action like creating, deleting etc can also be controlled by giving authority to specific group of users. So Drupal 8 user management also includes permissions and user roles.
  • In general terms, Roles are user groups which can be assigned specific authority through permissions so that they can perform certain action on website. Default roles in Drupal 8 are Anonymous user, Authenticated users and Administrator. You can create new roles like editor, manager etc.
  • Understanding roles and permissions is essential for managing different actions associated with website administration. Each module has certain actions which can be performed either by users or administrators. These actions are defined by the module developer in the code and administrator need to delegate authority for these actions. For example Taxonomy module has lot of features. Actions like Administer vocabularies and terms , edit term in particular vocabulary, delete term in particular vocabulary has to be performed by someone who is authorized.Similarly editors can have permissions to edit content, manager can delete content etc.
  • Each module is meant for some specific purpose. For example user module provides option to create user, delete user, edit user etc. So the authorities who can perform these action need to be defined for administrative purpose. So the permissions can be assigned from this interface for each of these actions to specific roles.
  • The above discussion about user roles, their permissions for actions, creation of user or editing specific user are main aspect of user management.
  • User registration is also one of the process which is connected with Drupal 8 user management. Drupal 8 user module has registration and login feature. As we discussed in last article for Drupal 8 website configuration, the configuration section has option to enable/disable user registration. Different options of user registration can be configured from Configuration section.

I hope that this basic idea of Drupal 8 user management will help you in understanding Drupal.

How to create website with Drupal 8 – Website configuration

After you install Druapl 8, you can login into Drupal system as administrator. Administrator is top most authority for this Drupal 8 installation who has all the rights of user management, configuration etc. Drupal 8 has lot of options and features which are configured by the administrator or other authorized users. Configuration sections has options for general settings of the website and it can be accessed from Primary menu.

Drupal 8 website configuration

Drupal 8 website configuration

System

  • Site Information – These are general settings for Drupal 8 system like website name, slogan, default front page and error pages etc
  • Cron – Drupal 8 runs certain tasks periodically like update check, content indexing to search engines etc. You can set time interval for cron or run the cron manually.

Media

Each website use different media types like images,video etc . Administrator can set different styles for images like small image, medium image, large image etc. There are multiple effects available like crop, resize, rotate,scale etc which can be applied on uploaded image.

REGIONAL AND LANGUAGE

As the name suggest, administrator can set default time zone, country and date/time for this website.

PEOPLE

As you will see that there is a People section in primary menu also which has option for Drupal 8 user management and access control but the People option in Configuration section has general settings for user management.

There are certain general settings for user registration and cancellation. You can configure different types of email messages for account activation, cancellation, password recovery etc.

There is one important thing to remember about the user registration. The default user registration form has few fields like user name, password, email etc. If you want to collect additional information during user registration, you can add more fields by Add field option in Manage Fields tab.

DEVELOPMENT

  • There is one important setting in this section i.e Performance . As we know that Drupal 8 is a complex system and dynamic page generation may take time so its better that visitors are supplied information from the cached content. Page Caching drastically improves the performance of website.
  • Drupal 8 also provides option to aggregate CSS and JS files which is essential for reducing the number of http request. In my point of view, you must select the caching option and CSS/JS aggregate option for better performance.
  • You also get option to put website in maintenance mode.

There are few other options Like RSS publishing , search and meta information etc for Drupal 8 website configuration which you can explore easily.

I hope , you could have understood the basic set of options in the Drupal 8 website configuration section.

How to build a website with Drupal 8

Drupal 8 is improved a lot over its previous versions.It is mobile friendly, feature rich, highly configurable, secure and highly extensible for various requirements. Before going further, let me briefly describe Drupal 8. First basic question may be What is Drupal, How it is different.

drupal 8 logoDrupal is a Content management system. You may treat it as framefork also but let me confine this discussion to Drupal 8 as CMS. There are several open source CMS like WordPress, Joomla etc. Basic purpose of all CMS is same i.e Content management but they all differ for the features they provide to users. WordPress is most simple with limited development features. On the other hand Drupal 8 is a feature rich CMS and offers lot of options for complex site development.

Initially Drupal 8 system look slightly complex but little understanding of terms and system makes it easier. Drupal complexity benefits users by offering several configuration options which other CMS does not so use Drupal 8 if you want to develop some website which is more than just few article pages or more than just a blog.

Creating a website with Drupal 8 requires basic understanding of Drupal system. If you understand Drupal 8 way of working, then you can create highly complex website easily. Drupal 8 has a core which includes kernel and several other modules.Core internal system includes routing of url requests, loading of files,modules,libraries,database etc. Core modules provides several inbuilt features like user, node (primary element which store individual content), taxonomy, forum, search, view etc.

In other terms,Drupal is flexible for adding new features , Drupal is flexible for look and feel of website. If you want to have some feature which is not available in default core package then you can download specific module for new feature and install it. Similarly you can change look and feel of website by changing the theme. Different types of themes are available for Drupal 8 website.

Lets start understaing the Drupal 8 system

Drupal 8 administration

The above Diagram shows different menu options available in Drupal 8 admin panel. Different features of Drupal 8 are divided among these categories.I just briefly state each of these option so that you can have basic idea of Drupal 8 administration.

  • Help – This section is for different help topics
  • Reports – The reports section provides options for different reports like error log,message log, available update etc.
  • People – This is place where you have options for user management. In addition, you can create different roles and accord permission to each role for specific task of website.
  • Configuration – This has options for configuration of website standard parameters like website name, email, region settings, date & time settings etc.
  • Extend – This section shows different modules installed in your Drupal 8 system.You can add new module, remove existing modules and activate/deactivate installed module.
  • Appearance – This section shows the installed themes in the system. You have option to install new theme, remove existing theme and control different parameters of theme for look and feel of website.
  • Content – This section has option for creating and managing content for website.Similarly you have option for comment management and file management in this section. Content may be just a Article for most of content management system but it has much broader role in Drupal 8 system. Content can be blog post, user profile, job posting,product review, product detail etc. Here these are different content type. Why are these different? Because each one has different fields for content insertion. A content type for a product detail may have fields like product pics, product title, product rating, product price, product specification, discount etc. Different types of website has their own specific content and its responsibility of Content management system to store content in database. You require a form to insert content in database and each form can have different fields.So the group of fields in a form represents specific information i.e content type. Most of the content management system provide only one type of content i.e article but drupal allows you to create multiple content type with each having specific input fields. The structure section of Drupal 8 administration allows you to create content type which we will see in next structure section.
  • Structure – This is the heart of Drupal 8 system. It allows to create structure of website. There may be a question ? What are the elements which define the structure of a website.
    • What type of information you want to display in your website – Create Content type
    • How you wish to group or link your content – Create Taxonomy
    • Each webpage has multiple section in template i.e Header, footer, sidebar etc.It means that webpage can be divided among multiple blocks so what you want to display in each block – Configure block in Block Layout
    • Where and how you want to display menu on webpage – Create and configure Menus
    • You created content type to store different types of information in database. But how you like to display information to viewers. – Create Views
    • Each site has contact us page. What fields you would like to display and how you like to display contact us page – Create and configure Contact forms.
    • Mostly websites include a comment system in their page to get feedback on their information. There are lot of parameters for a comment system. How can you create a specific comment system for you site – Create Comment types.

So in this way Drupal 8 allows you to control each and every bit of structural element. I will discuss each of the section in detail later but the broad idea of Drupal 8 system is must to avoid confusion while learning.

I will suggest users that first you check out easiest things then slowly move further. Drupal 8 has lot of features , dont get confused. First understand different sections of admin menu. I can say that first you develop understanding on sections Help, Extend, appearance, configuration,Reports,People. These six sections can be understood easily. Then you move on content section where default content types Article and Basic Page are available.Just create a sample article or basic page and view that individual piece of content on page.

The most crucial part is Structure. It takes some time to understand and practise. First you create a content type with simple fields.Then go again to Content section and add content. Here you select your recently created Content Type.Now insert some info in the fields.Check the saved result.

This is the begineing of Drupal 8 administration. I will discuss each of the section in next few articles. I hope that i could convey some understanding to reader. My objective is to convey basic understanding in simple terminology.

How to install Drupal 8 in your local computer

Drupal is one of the powerful CMS. Its latest version 8 is in beta stage and shortly it is expected that final versions will be released after removal of critical errors. Drupal offers large set of customization options. If you broadly define difference between WordPress, Joomla and Drupal then you can say that WordPress is simplest by offering few customization feature and Drupal is most complex out of these three due to large set of customization options. Joomla lies between these two.

Install drupal 8

Installing Drupal in local PC is quite a simple task. It is similar to installing other CMS in local environment. You need to create a local web server which you can easily do by installing XAMPP. If you never created a local web server then you may read last article on how to create local web server.

After you create local web server, you may proceed to install Drupal 8. First you download latest copy of Drupal. I am more focusing on Drupal 8 and testing it on my local PC so I recommend same. You can download Drupal latest core from Drupal website. Look at the steps for installing Drupal in your local computer.

  1. Create a XAMPP local web server & start Apache and MySQL modules from control panel
  2. Download Drupal core and unzip Drupal core.
  3. Copy unzipped Drupal folder in htdoc directory of XAMPP webserver (C:\xampp\htdocs)
  4. You can give a suitable name to unzipped drupal folder like drupal,drupal8, or else
  5. Now type the drupal folder url in browser like http://localhost/drupal/ and proceed for installation.
  6. Drupal installation completes in 6 stages. In first stage it ask to choose installation language. 2nd stage ask for installation profile i.e standard or minimal starts. Standard installation provides commonly used preconfigured features whereas minimal installation provides option for selecting different features. This is meant for advanced users who want specific installation package.
  7. On next stage, Drupal installation package check for installation requirements. If everything is ok then it proceeds for next stage otherwise it informs for necessary changes.
  8. On 4th stage, you need to setup database. You just provide database name, user name and password. You need not to create database separately. Drupal installation package creates database. You can choose any name for database. In case of XAMPP server generally the user name is root and password is left blank.
  9. On 5th stage, Drupal installation package installs the core.
  10. On the last stage, site configuration parameters can be setup like Site name, Site email address, user name, login password etc.
  11. Now Drupal installation packages finishes installation and opens the front page of site. You can now login and start working as site administrator.

Deal with Drupal Installation errors

Drupal installation requires few changes in php.ini file of your XAMPP server. There are several types of error which users faced so it is advisable to make following changes in php.ini file before starting the Drupal installation. The php.ini file is located in  \xampp\php\php.ini . It is important to state that php fileinfo extension is must for Drupal 8 installation so don’t forget to uncheck this setting in php.ini

max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 21M
mysql.connect_timeout = 600

extension=php_fileinfo.dll

I hope this would have helped you to install Drupal 8 in your local computer.