When obtaining the node types on a given Drupal site in Drupal 7 we use:

$types = node_get_types();

And the content type machine name is available from:

$names = array();
foreach ($types as $type) {
  $names[] = $type->type;

In Drupal 8 we use the following:

use Drupal\node\Entity\NodeType;

$types = NodeType::loadMultiple();
$names = array();
foreach ($types as $type) {
  $names[] = $type->id();

In Drupal 8 $type->type is protected.  The Node Type class protects all variables but some items are available via functions eg:


isNewRevision() - whether or not a new revision is created each time

displaySubmitted() - whether or not to display author details





Blog comments

Submitted by martinluth123 on Sat, 01/14/2017 - 06:29


How essay writing can enhance professional career
Essay writing is vital to your professional career. If you learn foreign languages, you will have to be able to prepare good essays; otherwise, you cannot master a foreign language. You should be able to write. When you plan to work as a journalist, you will need to be a good writer to complete catchy articles and organize the best interviews. Then, if you are an entrepreneur, you should be able to compose good essays too advertising your business plans and projects. Every applicant who wants to find a job is supposed to write a CV. If you cannot write this personal essay about your strong sides and professionalism, you will not find a good job. Thus, essay writing is important in every field of human life. Education, business and career making require at least basic knowledge about essay writing. http://www.essayjaguar.com

Submitted by dogra on Fri, 04/21/2017 - 09:50


Wishing you the best of luck for all your blogging efforts.This is my first opportunity to chat this website. I found some interesting things and I will apply to the development of my blog.
BBA College in Punjab
Best mechanical engineering college in punjab

User login