如何删除 Drupal 视图中显示的节点?

发布于 2024-12-01 16:12:18 字数 202 浏览 2 评论 0原文

Drupal 6。

我创建了一个节点类型,其中仅包含一个正文文本字段(标题使用 auto_nodetitles 隐藏),并且我通过视图显示该类型的所有节点。

我希望节点的作者能够单击视图中节点项旁边的“删除”链接以将其删除(就像通常通过 /admin/content/node/overview 删除节点一样)。

执行此操作的最佳方法是什么?

Drupal 6.

I have created a node type which consists of just a body text field (the title is hidden using auto_nodetitles), and I am displaying all nodes of this type through a view.

I want the author of the node to be able to click a "delete" link somewhere next to the node item in the view to have it removed (as you would delete a node through /admin/content/node/overview normally).

What is the best approach to doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

找个人就嫁了吧 2024-12-08 16:12:18

通过Views,可以输出节点编辑/删除链接;但是,您必须在管理页面中确认删除。

我建议您编写一个具有删除节点功能的自定义模块,但无需确认。按照以下步骤编写这个简单的模块(您可以使用现有的自定义模块):

  1. 编写 hook_menu() 的实现,它定义一个带有通配符的菜单项,以接收节点 ID 作为参数(更多内容请参见此处) 此处)
  2. 添加一个函数,您应在其中传递节点 ID 并调用 node_delete()
  3. 在视图中,添加将节点:nid添加到视图的字段中,但从显示中排除它
  4. 添加自定义文本视图字段(在选项中选择将其输出为链接),然后写入您在1中选择的URL
  5. 不要忘记使用“[nid]”作为通配符
  6. 利润。

Via Views, you can output node edit/delete links; however, you'll have to confirm the deletion as in the administrative pages.

I suggest you to write a custom module with the function to delete nodes, but without confirming. Write this simple module (you could use your existing custom module) following these steps:

  1. Write an implementation of hook_menu(), which defines a menu item with wildcard to receive the node ID as argument (more on this here)
  2. Add a function where you should pass the node ID and call node_delete()
  3. In Views, add node:nid to the view's fields, but exclude this from display
  4. Add a custom text view field (in options pick output this as link), and write URL you've chosen in 1
  5. Don't forget to use "[nid]" as wildcard
  6. Profit.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文