如何更改要显示的节点预览标题,而不是"预览"?
这是在自定义模块中解决问题的一种方法
/**
* implements hook_form_BASE_FORM_ID_alter
* the form id that will build the node preview is page_node_form
* @param $form
* @param $form_state
*/
function yourmodulename_form_page_node_form_alter( $form, $form_state ){
if( !empty( $form_state['node']->in_preview ) ){
// security hint: do not pass the PASS_THROUGH param to the drupal_set_title
// because the node title may contain some xss. Without this parameter the
// drupal_set_title will check for xss and remove them if present
drupal_set_title(t('Preview') . ' ' . $form['#node']->title );
}
}
在这里如何破解核心来修改标题(快速简便的方法(,但最好是通过自定义模块覆盖(也许其他人可以发布(。
in/modules/node/node.pages.inc添加 $node->title
drupal_set_title(t('Preview'), PASS_THROUGH);
喜欢:
// Display a preview of the node.
if (!form_get_errors()) {
$cloned_node->in_preview = TRUE;
$output = theme('node_preview', array('node' => $cloned_node));
unset($cloned_node->in_preview);
}
drupal_set_title(t('Preview: '.$node->title), PASS_THROUGH);