Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * @file
- * This module provides a node type called job post
- */
- /**
- * Implements hook_node_info() to provide our job_post type.
- */
- // function job_post_node_info() {
- // return array(
- // 'job_post' => array(
- // 'name' => t('Job Post'),
- // 'base' => 'job_post',
- // 'description' => t('Use this content type to post a job.'),
- // 'has_title' => TRUE,
- // 'title_label' => t('Job Title'),
- // 'help' => t('Enter the job title, job description, and the name of the company that posted the job'),
- // ),
- // );
- // }
- function node_type_save($info) {
- $existing_type = !empty($info->old_type) ? $info->old_type : $info->type;
- $is_existing = (bool) db_query_range('SELECT 1 FROM {node_type} WHERE type = :type', 0, 1, array(':type' => $existing_type))->fetchField();
- $type = node_type_set_defaults($info);
- $fields = array(
- 'name' => t('Job Post'),
- 'base' => 'job_post',
- 'description' => t('Use this content type to post a job.'),
- 'has_title' => TRUE,
- 'title_label' => t('Job Title'),
- 'help' => t('Enter the job title, job description, and the name of the company that posted the job'),
- );
- if ($is_existing) {
- db_update('node_type')->fields($fields)->condition('type', $existing_type)->execute();
- if (!empty($type->old_type) && $type->old_type != $type->type) {
- entity_invoke_bundle_hook('rename', 'node', $type->old_type, $type->type);
- }
- module_invoke_all('node_type_update', $type);
- $status = SAVED_UPDATED;
- }
- else {
- $fields['orig_type'] = (string) $type->orig_type;
- db_insert('node_type')->fields($fields)->execute();
- entity_invoke_bundle_hook('create', 'node', $type->type);
- module_invoke_all('node_type_insert', $type);
- $status = SAVED_NEW;
- }
- // Clear the node type cache.
- node_type_cache_reset();
- return $status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement