hello everyone.
i've written module for adding custom node type.
here is the code of la_article.module:


function la_article_nod_info() {
	return array(
		'la_article' => array(
			'name' => t('Litarmenia article'),
			'module' => 'la_article',
			'description' => t("Creation of articles for Litarmenia magazine."),
			'has_title' => true,
			'title_label' => t("Название статьи"),
			'has_body' => true,
			'body_label' => t("Тело статьи"),
			'min_word_count' => 5000
		)
	);
}

function la_article_perm() {
	return array('create Litarmenia article', 'edit Litarmenia article');
}

function la_article_access($op, $node, $account) {
	if ($op == 'create') {
		return user_access('create Litarmenia article', $account);
	}
	
	if ($op == 'update' || $op == 'delete') {
		if (user_access('edit Litarmenia article', $account) && ($account->uid == $node->uid))
		 return true;
	}
}

function la_article_form(&$node) {
	$type = node_get_types('type', $node);
	
	if ($type->has_title) {
		$form['title'] = array(
			'#type' => 'textfield', 
			'#title' => check_plain($type->title_label),
			'#required' => true,
			'#default_value' => "ashot",
			'#weight' => -5
		);
	}
	
	if ($type->has_body) {
		$form['body_field'] = node_body_field($node, $type->body_label, $type->min_word_count);
	}
	
	$form['myfield'] = array(
		'#type' => 'textfield',
		'#title' => t("myfield")
	);
	
	return $form;
}

then i have enabled it through Administer » Site building » Modules.
i didn't know what to do then, for adding custom node type, so i decided that i must add content type from Administer » Content management where in "Type" field i have written my module name (la_article).
then i wanted to make a test. i clicked on "Create content" link.
when i have selected node type that i created i found that fields are different from what i defined.
so, the question is, how i can add node that would be managed by my module?

Comments

yelvington’s picture

I'm not even going to read past "function la_article_nod_info() {"

zythar’s picture

emm? what do you mean?

arritjenof’s picture

yelvington, that was very helpfull. thank you.
zythar, mr. yelvington means: you have a typo in your first line (…nod…)

zythar’s picture

oh.. it was very funny (*
yelvington, arritjenof thank you very much!!