What to put in "type" when adding new content to node via $node->content
I'm adding new content to a node, but I'm stuck on what to put in #type
. I know that when you're dealing with a profile page for example, you would put
'#type' => 'user_profile_item'
but what to put for new content on a node?
$node->content['newc'] = array(
'#type' => , //what to put here for type
'#title' => t('开发者_如何学GoNew'),
'#value' => $newc,
}
That would be the node type. You can find this out by going to the content types edit page for that type of node. It's under a field called machine readable name or something like that. It's basically the kind of content you are creating; page, article, product, image etc.
For example if you had a content type 'Motor Vehicles' the node type might be 'motor_vehicles' as you cannot use spaces.
If you want something displayed on the node page with a title, you'll likely want to use '#type' => 'item'. Otherwise just to display some kind of output/markup the only thing you need is '#value' => 'the html or theme output here'.
Is this supposed to be a form field, such as a textbox? If so, you can use this: 'textfield'
If this isn't a field for a user to complete, but just a way to insert new content into the database with code, I'm not sure what it should be. In that case, you might want to not set the type at all and see if it works.
精彩评论