删除nidereference自动完成中的[nid:n] [英] Removing [nid:n] in nodereference autocomplete
问题描述
页面标题[nid] :23]
我知道这样可以确保选择在节点具有相同标题的情况下是唯一的,但是显然,这是暴露给用户的讨厌的事情。
有没有人有任何成功删除这些方括号或添加不同的唯一标识符?
最终,您需要更改nodereference.module中 nodereference_autocomplete()
的输出。 / p>
要正确执行此操作,您需要自定义模块来清理该功能。
此函数定义为菜单回调,因此,
/ **
*实现hook_menu_alter()。
* /
函数custom_module_menu_alter(& $ items){
$ items ['nodereference / autocomplete'] ['page callback'] ='custom_module_new_nodereference_autocomplete'
}
然后,将nodereference_autocomplete函数复制到您的自定义模块中,将其更改为匹配的名称你的回调。然后更改这一行:
$ matches [$ row ['title']。[nid:$ id]] ='< div class =reference-autocomplete>'。 $ row ['rendered']。 < / DIV>;
删除nid引用。
$ matches [$ row ['title']] ='< div class =reference-autocomplete>'。 $ row ['rendered']。 < / DIV>;
我相信标识符在这一点上是纯粹的化妆品,这意味着你也可以更改文本,但是喜欢。如果不是纯粹的化妆品,那么我没有测试过,看看在错误的条件下会发生什么。
我总是想确定如何做到这一点。谢谢你激励我的问题。
Using the autocomplete field for a cck nodereference always displays the node id as a cryptic bracketed extension:
Page Title [nid:23]
I understand that this ensures that selections are unique in case nodes have the same title, but obviously this is a nasty thing to expose to the user.
Has anyone had any success in removing these brackets, or adding a different unique identifier?
Ultimately, you need to change the output of nodereference_autocomplete()
in nodereference.module.
To do this properly, you want a custom module to cleanly override the function.
This function is defined as a menu callback, thus,
/**
* Implementation of hook_menu_alter().
*/
function custom_module_menu_alter(&$items) {
$items['nodereference/autocomplete']['page callback'] = 'custom_module_new_nodereference_autocomplete';
}
Then, copy the nodereference_autocomplete function into your custom module, changing it's name to match your callback. Then change this one line:
$matches[$row['title'] ." [nid:$id]"] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
Dropping the nid reference.
$matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
I believe the identifier is purely cosmetic at this point, which means you could also change the text however you like. If it is not purely cosmetic, well, I haven't tested to see what will happen in the wrong conditions.
I always meant to identify how to do this. Thank you for motivating me with your question.
这篇关于删除nidereference自动完成中的[nid:n]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!