| Joomla! http://forum.joomla.org/ |
|
| Delete button on frontend hack http://forum.joomla.org/viewtopic.php?f=32&t=9196 |
Page 1 of 1 |
| Author: | silverfish [ Wed Sep 28, 2005 11:42 pm ] |
| Post subject: | Delete button on frontend hack |
I have modified two files and have created a "Trash" button on the front end so users can delete their own articles. If anyone is interested, the hack is posted below (please back up each file mentioned before changing them): Open components\com_content\content.php and under this line: Code: case 'save': Add this line: Code: // Trash hack case 'remove': removeContent( $id, $sectionid, $option ); break; //End Trash hack Then add this code after the 'SaveContent()" function, around line 1450 Code: // RemoveContent hack function removeContent( $id, $sectionid, $option ) { global $database; $state = '-2'; $ordering = '0'; //seperate contentids $query = "UPDATE #__content" . "\n SET state = $state, ordering = $ordering" . "\n WHERE id = $id" ; $database->setQuery( $query ); if ( !$database->query() ) { echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } $msg = $total ." Item(s) sent to the Trash"; $return = mosGetParam( $_POST, 'returntask', '' ); mosRedirect( 'index.php' ); } // End Remove Content Hack Save the file. Now open includes\HTML_toolbar.php, add this code after the savenew() function. Around line 305. Code: /** * Write a trash button that will move items to Trash Manager */ function trash () { $image = mosAdminMenus::ImageCheck( 'delete_f2.png', '/administrator/images/', NULL, NULL, 'Trash', 'remove', 1 ); $js = "javascript:if (confirm('Are you sure you want to delete this item?')){ submitbutton('remove');}"; ?> <td> <a class="toolbar" href="<?php echo $js; ?>"> <?php echo $image; ?></a> </td> <?php } Save the file. Now open components\com_content\content.html.php. Add this code after mosToolBar::apply( 'apply_new' ); Code: // Add Trash button mosToolBar::trash(); // End Trash Button Your code should look like this for the toolbar: Code: // Toolbar Top mosToolBar::startTable(); mosToolBar::save(); mosToolBar::apply( 'apply_new' ); // Add Trash button mosToolBar::trash(); // End Trash Button mosToolBar::cancel(); mosToolBar::endtable(); Hope this helps people out. Silver |
|
| Author: | joomlamoves [ Wed Oct 26, 2005 11:33 pm ] |
| Post subject: | Re: Delete button on frontend hack |
this helped out a lot. thank you for taking the time to post this. |
|
| Author: | tommy2toes [ Sun Jun 11, 2006 8:47 am ] |
| Post subject: | Re: Delete button on frontend hack |
hmm, i tried this it didn't work... |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|