3
votes

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?

1

1 Answers

3
votes

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.