Creating Custom Content Types Programmatically in Drupal 10

Content types are the backbone of content management in Drupal. In Drupal 10, you can create custom content types to structure and organize your content. This blog post will guide you through the process of creating content types programmatically in Drupal 10, allowing you to tailor your website's content structure to your specific needs.

Prerequisites

Before creating custom content types programmatically in Drupal 10, you should have the following:

  1. A working Drupal 10 or 9 website.
  2. Basic knowledge of Drupal site building and module development.
  3. Familiarity with PHP and Drupal's module structure.

Step 1: Define the Custom Module

To create a custom content type programmatically, you need to place the code in a custom module. If you don't already have a custom module, you can create one by following these steps:

  1. In your Drupal installation, navigate to the sites/all/modules directory (or your preferred module location).
  2. Create a new directory for your custom module. Give it a unique and descriptive name, such as my_custom_content_type.
  3. Inside your module directory, create a my_custom_content_type.info.yml file with the following content:
name: 'My Custom Content Type Module'
type: module
description: 'Defines custom content types programmatically.'
core_version_requirement: ^9 || ^10
package: Custom
dependencies:
  - node

This YAML file defines the basic information about your custom module.

Step 2: Create a Custom Content Type

To create a custom content type, you'll need to implement the hook_entity_type_build and hook_node_type_insert hooks within your custom module.

  1. Create a file named my_custom_content_type.module in your module directory.
  2. In this file, implement the hook_entity_type_build hook to define your custom content type. Here's an example:
/**
 * Implements hook_entity_type_build().
 */
function my_custom_content_type_entity_type_build(array &$entity_types) {
  $entity_types['node']->setClass('Drupal\my_custom_content_type\NodeTypeCustom');
}

This code defines a custom class, NodeTypeCustom, to handle the configuration of your custom content type.

  1. Create the NodeTypeCustom class in a file named NodeTypeCustom.php and place it in your module's directory:
namespace Drupal\my_custom_content_type;

use Drupal\node\NodeTypeBase;

/**
 * Provides a custom content type.
 */
class NodeTypeCustom extends NodeTypeBase {

  /**
   * {@inheritdoc}
   */
  public function postSave(NodeTypeInterface $node_type) {
    parent::postSave($node_type);

    // Define the custom content type settings.
    $config = \Drupal::configFactory()->getEditable('node.type.' . $node_type->id());
    $config->set('name', 'Custom Content Type');
    $config->set('description', 'A custom content type created programmatically.');
    $config->set('new_revision', TRUE);
    $config->save();
  }
}

n the NodeTypeCustom class, we extend the NodeTypeBase class to define the custom content type settings, such as the name and description.

Step 3: Enable and Verify Your Custom Content Type

  1. In your Drupal admin interface, navigate to Extend (admin/modules) and enable your custom module, "My Custom Content Type Module."
  2. After enabling the module, go to Structure > Content types (admin/structure/types) to see your custom content type listed as "Custom Content Type."

Conclusion

Creating custom content types programmatically in Drupal 10 allows you to define content structures that fit your specific project requirements. By following the steps outlined in this blog post, you can easily create and configure custom content types within your Drupal website, providing a flexible and tailored content management experience.

In Drupal 9 and 10, custom modules should be stored in the "modules/custom" directory rather than "sites/all/modules." Drupal's module directory structure has evolved, and the recommended practice is to place custom modules in the "modules/custom" directory to follow the modern Drupal standards.

So, if you're creating a custom module in Drupal 9 or 10, you should place it in the following directory:

/sites/all/modules/custom/

By following this structure, your custom modules will be more organized and adhere to Drupal's best practices, making it easier to manage and maintain your site's codebase.

Share on social media

Comment

Permalink

Fair warning up front, tracker docs tend to bury the useful parts. What surprised me is how much legwork this page removes from evaluating a new setup. Instead of bouncing between help articles, pricing pages and forum threads, you get one walkthrough that covers ad tracking and spend matching in a single pass. That means fewer open tabs and fewer hours lost to comparing scattered notes on how spend gets reconciled against campaign data. For anyone testing tools before a migration, the time saved on setup research alone is worth the read, and you come away with a clearer checklist of what to verify in your own account.

Permalink

Last quarter I watched a colleague burn two days rebuilding voice samples because nobody had read the setup notes first. The basics are boring until skipping them costs you a week of retakes. Clean input audio, a consistent naming habit for your clones and a clear idea of what each plan allows are the three things that prevent most headaches later. The page walks through the tool's plans and cloning workflow in enough detail that you can plan around the limits instead of discovering them mid-project. If you are about to hand this tool to a team, read the overview before anyone uploads a single file; details at https://notes-to-outlook.com/tools/hub/app-uberduck-ai-notes/ cover what the free tier gives you and where the paid options start. It is the kind of reading that pays for itself the first time a project does not stall.

Permalink

Choosing an ad spy tool on hype alone is a mistake beginners make constantly, and it usually ends with a subscription nobody uses. Reading a careful AdMobiSpy review first changes that, because it walks through what the platform actually shows you once you log in. Instead of guessing from a landing page, you see the ad research features described in plain terms, so you can compare them against the questions you already have about competitor campaigns. The page also covers access levels, which matters more than most people admit at the start. Beginners tend to assume every plan unlocks the same data, then get surprised later. Going in with a clear picture of what each tier offers keeps you from paying for capacity you will never touch and from hitting a wall the moment your needs grow.

Permalink

You are midway through a release checklist when a signup form starts rejecting test addresses, and you need a working inbox in seconds rather than a research project. That is when a saved reference beats a search engine. Keep the page bookmarked next to your test scripts so you can jump straight to the endpoint details, confirm how addresses are issued, and check whether messages persist long enough for your flow. On slower days, the same page is useful for explaining to a teammate why disposable mail behaves differently from a normal mailbox, or for sanity-checking a helper function before you commit it. Details sit at https://iankim.net/articles/lookup/inside-guerrillamail-com/ and load fast enough to consult mid-task. Treat it as documentation you reach for repeatedly, not a one-time read.

Permalink

A colleague once said the Affinity name keeps popping up and nobody can tell me what it actually is. Fair question, and the answer is mostly about scope. The Affinity ad network review on this page lays out what the platform covers on the publisher side and where CPA deals fit into the picture, without dressing it up as a revolution. It helps that the write-up treats the index itself as a tool for comparison rather than a ranking to chase. You get a sense of the categories being weighed, the kind of traffic each model suits, and the questions you should be asking before you sign anything. If you have ever been handed a network pitch and felt the details were missing, this fills that gap in a few minutes of reading.

Permalink

Reviews only mean something when you know who wrote them. The page takes that seriously and treats SMS verification reviews as data to be read critically, not scores to be trusted at face value. It discusses how feedback can be gamed, what patterns suggest genuine user reports, and which details in a review tell you more than a star rating. From there, the natural next step is learning how to test a provider yourself: start small, check delivery on the platforms you care about, and watch how support handles a failed code. That habit of verification carries over to almost any online account you set up, which is why the article is worth bookmarking. If you have already read the basics on activation, this is the follow-up that turns a casual glance at reviews into something closer to an informed decision.

Permalink

Aviator, Keno 80 playaviator.netlify app and four other crash games—all covered in a single review for users in Ethiopia. Explore gameplay mechanics, compare RTP rates and betting ranges in ETB, and learn how to use Telebirr to top up your account and manage your payments.

Permalink

Looking for crash games aviatorgames onrender in Cameroon? Our 2026 review features Aviator and five other games, complete with descriptions of their rules, RTP, gameplay features, and available payment options. Compare their specifications and learn about the potential risks involved.

Permalink

Explore crash games aviatorcrash.vercel.app in Cameroon in 2026: learn about game mechanics, round features, RTP rates, available bets, and deposit methods. Compare various online entertainment options and familiarize yourself with the rules for participating.

Permalink

Crash games in Cameroon aviatorgame.neocities org in 2026: a comprehensive guide to Aviator and five alternatives. We break down the rules, gameplay mechanics, RTP, betting options, and the use of various payment services. Get an overview of the available formats and the terms and conditions for playing online.

Permalink

Looking for crash games https://aviatorgames.onrender.com/ in Cameroon? Our 2026 review features Aviator and five other games, complete with descriptions of their rules, RTP, gameplay features, and available payment options. Compare their specifications and learn about the potential risks involved.

Permalink

Penalty Duel https://penaltyduelgame.wasmer.app is a unique type of crash game designed for football fans in Ivory Coast. Learn about the rules, game rounds, odds, and betting features. This detailed review will help you understand the game's mechanics.

Permalink

الدوري السعودي aldawriu-alsueudiu تابع أحدث جدول للترتيب، ونتائج الفرق، ومواعيد مباريات اليوم. اطّلع على مراكز الأندية، وإجمالي النقاط، وتوقيتات انطلاق مباريات كرة القدم القادمة.

Permalink

how to get amoxicillin over the counter and amoxicillin 500mg capsules antibiotic buy amoxicillin online without prescription
https://maps.google.bf/url?sa=t&url=https://getsynapsefuel.com amoxicillin without a doctors prescription or http://www.sportchap.ru/user/hvzasitllm/ order amoxicillin no prescription
how much is amoxicillin prescription buy cheap amoxicillin online or amoxicillin for sale amoxicillin buy canada

Permalink

GetSynapseFuel: modafinil - provigil and buy modvigil no prescription: SynapseFuel - cheap generic provigil provigil: provigil - order modalert 200mg online
https://image.google.com.sl/url?q=https://getsynapsefuel.xyz cheap generic provigil: SynapseFuel - Get Synapse Fuel or https://gikar.it/user/zcilfxsbpa/ buy modvigil no prescription: Get Synapse Fuel - GetSynapseFuel
buy modvigil no prescription: modafinil - GetSynapseFuel Get Synapse Fuel: buy modvigil no prescription - GetSynapseFuel and cheap generic provigil: provigil - cheap generic provigil GetSynapseFuel: Get Synapse Fuel - buy modafinil online

Permalink

أسعار الذهب في المملكة https://aisear-aldhahab.pro العربية السعودية اليوم بالريال: الأسعار الحالية لعيارات 24 و22 و21 و18 قيراطاً للجرام الواحد. تابع تقلبات الأسعار، وقارن بين المعدلات، واحسب تكلفة المشغولات الذهبية.

Permalink

أسعار الذهب في المملكة aisear-aldhahab pro العربية السعودية اليوم بالريال: الأسعار الحالية لعيارات 24 و22 و21 و18 قيراطاً للجرام الواحد. تابع تقلبات الأسعار، وقارن بين المعدلات، واحسب تكلفة المشغولات الذهبية.

Permalink

مواقيت الصلاة في المملكة https://sala-sa.pro العربية السعودية اليوم — الجدول الحالي للصلوات الخمس اليومية. تعرّف على أوقات صلوات الفجر، والظهر، والعصر، والمغرب، والعشاء في الرياض، ومكة المكرمة، والمدينة المنورة، ومدن أخرى.

Permalink

حالة الطقس في المملكة al-taqs.pro العربية السعودية اليوم وغداً: أحدث التوقعات لدرجات الحرارة، وهطول الأمطار، والرياح، والرطوبة. تعرّف على الظروف الجوية المتوقعة في الرياض، ومكة المكرمة، والمدينة المنورة، وجدة، وغيرها من المدن في مختلف أنحاء المملكة.

Permalink

مواقيت الصلاة الحالية في المملكة https://www.awqat-alsala.pro العربية السعودية لهذا اليوم. جداول الصلاة في مكة المكرمة، والمدينة المنورة، وجدة، والرياض، ومناطق أخرى، وتشمل أوقات صلوات الفجر، والظهر، والعصر، والمغرب، والعشاء.

Permalink

مواقيت الصلاة في المملكة https://sala-sa.pro العربية السعودية اليوم — الجدول الحالي للصلوات الخمس اليومية. تعرّف على أوقات صلوات الفجر، والظهر، والعصر، والمغرب، والعشاء في الرياض، ومكة المكرمة، والمدينة المنورة، ومدن أخرى.

Permalink

Free online games playhopgames.website.yandexcloud net play directly in your browser, with no need to download or install any software. Choose from a variety of genres, including arcades, puzzles, strategy games, and racing, and start playing whenever it suits you.

Permalink

A 2026 catalog of applications https://uptodown.website.yandexcloud.net for Android and Windows — a collection of popular programs, mobile apps, and useful tools. Explore descriptions, features, and system requirements to choose the right software for your devices.

Permalink

Free online games crazygames-play for engaging leisure and entertainment, available anytime. Choose from popular genres, complete levels, solve puzzles, and discover new gaming titles—all at no cost.

Permalink

Want to play Snake www.snake.radio.fm online for free? Just launch the game in your browser, guide the character’s movement, collect food, and earn points. With its simple rules and engaging gameplay, it’s perfect for a quick break.

Permalink

Want to play Snake http://www.snake.radio.fm/ online for free? Just launch the game in your browser, guide the character’s movement, collect food, and earn points. With its simple rules and engaging gameplay, it’s perfect for a quick break.

Permalink

Looking for Snake games worm and apple game on Google Play? Explore a collection of mobile games featuring snakes, and compare their control schemes, graphics, difficulty levels, and extra features. Choose the Android apps that interest you most.

Permalink

Napdoku: Cozy Brain Puzzle 猫アプリゲーム is a relaxing logic game designed for brain training and unwinding. Solve number puzzles to sharpen your attention, concentration, and logical thinking skills as you progress through increasingly challenging levels.

Permalink

Looking for Snake games gogle worm on Google Play? Explore a collection of mobile games featuring snakes, and compare their control schemes, graphics, difficulty levels, and extra features. Choose the Android apps that interest you most.

Add new comment