Now that I have the ISBN2node module code working, I would like to extend it, maybe in a custom module. What I want to do is to "connect" it to an existing content type instead of having its own custom content type.

So I want to make a form that allows the user to choose a content type and then map fields from the book record (e.g. title, author, publication date, etc) over to fields in my content type.

What are the functions I need to look into, to let me do this?

I could of course just hard code all this into a custom module but it would be nice both for flexibility and for visibility from the UI to configure it with a form. If it's not too hard, that is. :)

Thanks.

Accepted answer

Use field_info_instances('node', 'card') for this. 

Most helpful answers

I'm not at a computer right now, so can't test the output, but node_type_load() should give you the info. Have a look in Devel's Execute PHP at the output from that

@argiepiano - thanks for your thoughts.

The question isn't specific to the module, though. I just mean when you go to the page /admin/structure/types/manage/your-content-type/fields, you can see a list of the fields that belong to your content type. What I am asking is, are there handy API functions that I could use to (1) grab that same list of fields, and (2) get a list of defined content types?

Comments

Hmmm... answering this would require understanding how that module works. Reading the description of the module, it's hard to tell.  Perhaps try Zulip to see if someone else using it or has used it?

@argiepiano - thanks for your thoughts.

The question isn't specific to the module, though. I just mean when you go to the page /admin/structure/types/manage/your-content-type/fields, you can see a list of the fields that belong to your content type. What I am asking is, are there handy API functions that I could use to (1) grab that same list of fields, and (2) get a list of defined content types?

I'm not at a computer right now, so can't test the output, but node_type_load() should give you the info. Have a look in Devel's Execute PHP at the output from that

Thanks, @yorkshirepudding! I looked at the function you mentioned, and it does load the "node type" data as you mentioned, but that does not appear to include its fields. Going to check the list of functions in the node module docs and see if I can spot the one I want.

None of the node module functions appears to give the info I was looking for, sadly.

This function gives the type definition but doesn't show the associated fields. E.g.

$type = node_type_load('card');
print_r ($type);

# results

stdClass Object
(
    [type] => card
    [name] => Card
    [description] => Add a card for use on an existing page. Display as a block or in a view.
    [settings] => Array
        (
            [status_default] => 1
            [node_preview] => 1
            [promote_enabled] => 1
            [promote_default] => 
            [sticky_enabled] => 
            [sticky_default] => 
            [revision_enabled] => 1
            [revision_default] => 
            [scheduling_enabled] => 
            [show_submitted_info] => 
            [comment_default] => 1
            [node_submitted] => 
            [node_user_picture] => 
            [hidden_path] => 1
            [comment_enabled] => 
            [comment_per_page] => 50
            [comment_mode] => 1
            [comment_anonymous] => 0
            [comment_title_options] => auto
            [comment_user_picture] => 1
            [comment_form_location] => 1
            [comment_preview] => 1
            [comment_close_enabled] => 
            [comment_close_days] => 14
            [menu_default] => 
            [menu_options] => Array
                (
                )

            [menu_parent] => main-menu:0
            [node_submitted_format] => [node:created:medium] by [node:author]
            [language] => 0
            [node_permissions] => 1
        )

    [base] => node_content
    [module] => node
    [node_preview] => 1
    [help] => 
    [modified] => 
    [disabled] => 
    [has_title] => 1
    [title_label] => Title
    [orig_type] => card
)

I'm going to look at the field module next to see if I can figure it out. It does look like the path I mentioned /admin/structure/types/manage/my-content-type/ only shows up in the field_ui module.

Use field_info_instances('node', 'card') for this. 

Thanks, @argiepiano! I'll go check that out right now.