I'm working to revive an old CMS and the current way of deleting posts in a forum thread is to select them via checkbox and then click delete. I'd like to avoid the numerous amounts of click and just have the user click "delete" on a single post and have that post be deleted.

It uses Smarty templating so this function is a bit convoluted.

<input type="checkbox" name="delcomm[]" value="{$posts[p].id}" style="width: auto; height: auto" /> <span style="font-size: 12px;">{t k="tpl_comments_delmark"}</span>

{t k="tpl_comments_delmark"} simply displays text that says "delete", dont worry about that. It passes $posts[p].id to the form and then deletes. I thought of simply making a link using $posts[p] but it doesnt seem to work:

<a href="{link url="forum/moderate/`{$posts[p].id}`/delete_replies"}">Delete</a>

For reference, once the user click "delete" in the normal checkbox way, the user is redirected to a confirmation page and in the url, you see /forum/moderate/[postnumber]/delete_replies (without []'s)

Any help?

Recommended Answers

All 3 Replies

Are you sure that you will get better user experience this way? If you let users delete each post without asking them for confirmation first thea are at risk deleting too many posts to quickly. If you ask them for consfirmation at each post they wish to delete you will make them click a lot (it is better to get the user click the checkboxes, press the delete button and ask for confirmation for all the selected posts to be deleted). This is just my opinion, others might dissagree.

If you want to use a link (or any html element) to trigger deletion you have two ways:
- using javascript onclick event and deleting with ajax call to a php script (recommended, but think about confirmation)
- using a querystring with the id of the post to be deleted (not recommended). This technique is highly discouraged since poses a big security issue. The query string is easily changed so deleting all posts is trivial.

I just dont like having the checkboxes. Its rare to have to delete more than one comment at a time, and its painfully ugly as well.

If I kept the checkbox style, is there a way to make it invisible until the user until they want to see them? Probably done with ajax I would assume

If I kept the checkbox style, is there a way to make it invisible until the user until they want to see them?

Make them hidden (style="visibility:hidden;") and a button somewhere that says something like 'Display delete checkboxes' and a javascript (called by onclick event) to change the visibility of all checkboxes to visible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.