尝试这个:
在目录 sites/all/modules 中创建一个名为stackexample
. 在该目录中,创建两个文件:stackexample.info
和stackexample.module
.
将以下代码放入stackexample.info
:
name = Stack Example
description = Displays a message with form values on pagename nodes.
core = 7.x
将以下代码放入stackexample.module
:
<?php
/**
* Implements hook_form_alter().
*/
function stackexample_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'pagename_node_form') {
// Trigger a message if arg(3) is set to "showtheform"
// e.g. node/add/pagename/showtheform
if (arg(3) == 'showtheform') {
drupal_set_message('<pre>' . check_plain(print_r($form, 1)) . '</pre>');
}
// This example will add a custom title to the revision info area if uncommented
// $form['revision_information']['#collapsed'] = FALSE;
// $form['revision_information']['#title'] = t('CUSTOM TITLE FOR REVISION AREA');
}
}
转到admin/modules
并启用该Stack Example
模块。
转到node/add/pagename/showtheform
查看所有可能性,并根据需要调整示例行。
注意:不建议在生产站点上启用此功能,因为没有采取任何安全措施,并且整个pagename
表单将暴露给任何有权创建pagename
节点的人(如果他们知道添加showtheform
到 url) .
HTH .. :)