edit_link.module in Util 7
Same filename and directory in other branches
Add an 'edit' link to nodes.
File
contribs/edit_link/edit_link.moduleView source
<?php
/**
* @file
* Add an 'edit' link to nodes.
*/
/**
* Implements hook_link().
*/
function edit_link_node_view($node, $view_mode) {
static $ntypes;
if ($view_mode == 'teaser' && node_access('update', $node)) {
$objtype = 'post';
if (variable_get('edit_link_type', 0)) {
if (!isset($ntypes)) {
$ntypes = node_type_get_names();
}
$objtype = $ntypes[$node->type];
}
return $node->content['links']['util-edit-link'] = array(
'#links' => array(
array(
'title' => t('Edit this @type', array(
'@type' => $objtype,
)),
'href' => "node/{$node->nid}/edit",
'attributes' => array(
'title' => t('Edit this @type', array(
'@type' => $node->type,
)),
),
),
),
);
}
}
/**
* Implements hook_settings().
*/
function edit_link_form_alter(&$form, $form_state, $form_id) {
$noyes = array(
t('No'),
t('Yes'),
);
switch ($form_id) {
case 'util_page':
$form['edit'] = array(
'#type' => 'fieldset',
'#title' => t('Edit Link Options'),
'#collapsible' => TRUE,
'#group' => 'node',
);
$form['edit']['edit_link_type'] = array(
'#title' => t('Show content type?'),
'#type' => 'radios',
'#options' => $noyes,
'#default_value' => variable_get('edit_link_type', 0),
'#description' => t("If this option is chosen, a post's content type will be shown in the edit link."),
'#attributes' => array(
'class' => array(
'container-inline',
),
),
'#prefix' => '<div id="edit-type">',
'#suffix' => '</div>',
);
}
}
Functions
Name![]() |
Description |
---|---|
edit_link_form_alter | Implements hook_settings(). |
edit_link_node_view | Implements hook_link(). |