Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 842821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:01:38+00:00 2026-05-15T06:01:38+00:00

Is it possible to declare and manage several custom content types inside one module?

  • 0

Is it possible to declare and manage several custom content types inside one module? I’m creating a site that needs four custom content types and I’d like to manage them from one module instead of creating module for every content type. After some testing, I found out that it seems impossible. Because, unless hook_form and content type share the same name of module, drupal doesn’t call hook_form.

Here’s how I’d like to do –

function mycontent_node_info(){
return array(
    'mycontent1' => array(
        'name' => t('....'),
        'module' => 'mycontent',
        'description' => t('...),
        'has_title' => TRUE,
        'title_label' => t('Title'),
        'has_body' => TRUE,
        'body_label' => t('content body'),
    ),
    'mycontent2' => array(
        .......
    ),
    'mycontent3' => array(
        ......
    ),
    'mycontent4' => array(
        ......
    ),
);
}

function mycontent1_form(&$node){
$form['control1'] = array(
    '#type' => 'select',
    '#options' => array(
        '0' => t('selection 1'),
        '1' => t('selection 2'),
    ),
    '#attributes' => array('id'=>'control1'),
);

$form['control2'] = array(
    '#type' => 'select',
    '#options' => array(
        '0' => t('1'),
        '1' => t('2'),
        '2' => t('3'),
        '3' => t('4'),
    ),
    '#attributes' => array('id'=>'control2'),
);   
return $form;
}

function mycontent2_form(&$node){
....
} 

function mycontent3_form(&$node){
    ....
} 


function mycontent4_form(&$node){
    ....
}  

Am I doing something wrong here or is not possible and there’s no alternative other than creating module for every content types. I appreciate much your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T06:01:38+00:00Added an answer on May 15, 2026 at 6:01 am

    The prefix for all your hooks should be the name of your module, i.e. mycontent_node_info() and mycontent_form(&$node). I think the content type itself can be called whatever you want but by convention anything global that you define in a module should be prefixed with the name of the module to avoid namespace problems. So your content becomes mycontent_type1, mycontent_type2, etc… As for dealing with hook_form, I guess the way to do it is to check the type of the node passed in and act accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to declare more than one variable using a with statement in
is it possible to declare more than 1 block in a module? I tried
Possible Duplicate: Cannot declare Public static final String s = new String(“123”) inside an
Is it possible to declare a function pointer (non C++ 11) that can point
Is it possible to declare class variable outside of if-else and initialize it inside
Is it possible to declare a constant Guid in C#? I understand that I
I am wanting to clarify if it is not possible to declare types in
in C#, is it possible to declare an Enum that is only visible within
Is it possible to declare that a column in MySQL should be unmodifiable once
Is it possible to declare a variable in Python, like so?: var so that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.