Find and replace template for node
I created this to make it easier to create simple nodes quickly using find & replace. It is for the final version of 4.7 and appears to work but I could be missing something as I am new to drupal. All you have to do is fill out the information above for technical-name, user-friendly-plural, etc and then, in a text editor, find and replace **technical-name**, **user-friendly-plural**, **etc** with that information. All the variables have **two asteriks** around them which need to be replaced as well.
<?php
// $Id: **technical-name**.module,v 1.186 2006/03/27 18:02:48 killes Exp $
/**
* @file
* Enables users to submit **user-friendly-plural**.
*/
/**
* Implementation of hook_help().
*/
function **technical-name**_help($section) {
switch ($section) {
case 'admin/help#**technical-name**':
$output = '<p>'. t('The **technical-name** module is used to create a content post type called <em>**user-friendly-plural**.</em> **help-description** ') .'</p>';
$output .= '<p>'. t('The **user-friendly-name** administration interface allows for complex configuration. It provides a submission form, workflow, default view permission, default edit permission, permissions for permission, and attachments. Trackbacks can also be enabled.') .'</p>';
$output .= t('<p>You can</p>
<ul>
<li>post a **user-friendly-name** at <a href="%node-add-**technical-name**">create content >> **user-friendly-name**</a>.</li>
<li>configure **user-friendly-name** at <a href="%admin-settings-content-types-**technical-name**">administer >> settings >> content types >> configure **user-friendly-name**</a>.</li>
</ul>
', array('%node-add-**technical-name**' => url('node/add/**technical-name**'), '%admin-settings-content-types-**technical-name**' => url('admin/settings/content-types/**technical-name**')));
$output .= '<p>'. t('**drupal-help-text** <a href="%**technical-name**">**user-friendly-name** page</a>.', array('%**technical-name**' => '**drupal-help-link**')) .'</p>';
return $output;
case 'admin/modules#description':
return t('**module-description**');
case 'node/add#**technical-name**':
return t('**create-content-description**');
}
}
/**
* Implementation of hook_node_info().
*/
function **technical-name**_node_info() {
return array('**technical-name**' => array('name' => t('**user-friendly-name**'), 'base' => '**technical-name**'));
}
/**
* Implementation of hook_perm().
*/
function **technical-name**_perm() {
return array('create **user-friendly-plural**', 'edit own **user-friendly-plural**');
}
/**
* Implementation of hook_access().
*/
function **technical-name**_access($op, $node) {
global $user;
if ($op == 'create') {
return user_access('create **user-friendly-plural**');
}
if ($op == 'update' || $op == 'delete') {
if (user_access('edit own **user-friendly-plural**') && ($user->uid == $node->uid)) {
return TRUE;
}
}
}
/**
* Implementation of hook_menu().
*/
function **technical-name**_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array('path' => 'node/add/**technical-name**', 'title' => t('**user-friendly-name**'),
'access' => user_access('create **user-friendly-plural**'));
}
return $items;
}
/**
* Implementation of hook_form().
*/
function **technical-name**_form(&$node) {
$form['title'] = array('#type' => 'textfield', '#title' => t('**title-caption**'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
$form['body_filter']['body'] = array('#type' => 'textarea', '#title' => t('**body-caption**'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
$form['body_filter']['format'] = filter_form($node->format);
return $form;
}