[SOLVED] Can't get my "delete" method working in Admin section
Posted: Tue Oct 19, 2010 3:39 pm
Hi all,
I'm working on my first module (and it's tough..), which generates a tagcloud based on tagwords that are taken out of a database. So far, everything works except the deletion part.
In my admin section I have two tabs: Add and Delete. The Add tab has a small inputbox and a submit button which works (although it doesn't return to the default tab after you entered something, but that's my least concern). In the Delete tab, all the keywords are gathered from the database and displayed in tabular format with a submit button (for deletion). If I press on a delete button, I get an empty screen in the adminsection (meaning that all the adminsections, like backgroundcolor, menu, and text) are there, but the spot where the module settings are is empty. If I go back to the list then, nothing is deleted.
This is the code for action.defaultadmin.php
and the code for action.process.php
Thanks in advance!
I'm working on my first module (and it's tough..), which generates a tagcloud based on tagwords that are taken out of a database. So far, everything works except the deletion part.
In my admin section I have two tabs: Add and Delete. The Add tab has a small inputbox and a submit button which works (although it doesn't return to the default tab after you entered something, but that's my least concern). In the Delete tab, all the keywords are gathered from the database and displayed in tabular format with a submit button (for deletion). If I press on a delete button, I get an empty screen in the adminsection (meaning that all the adminsections, like backgroundcolor, menu, and text) are there, but the spot where the module settings are is empty. If I go back to the list then, nothing is deleted.
This is the code for action.defaultadmin.php
Code: Select all
if( !isset(cmsms()) ) exit;
// choose the tab to display. If no tab is set, select 'shows' as the default
// tab to display, because - in my opinion - this is the mostly needed tab.
if (!empty($params['active_tab']))
$tab = $params['active_tab'];
else
$tab = 'toevoegen';
// and finally, display all those tabs. First, setup the tabs, and than include
// the function.{tab}.php file, in which the tab's code is stored to keep this
// file a bit tidier.
echo $this->StartTabHeaders();
echo $this->SetTabHeader('toevoegen', 'Toevoegen', 'toevoegen' == $tab ? true : false);
echo $this->SetTabHeader('verwijderen', 'Verwijderen', 'verwijderen' == $tab ? true : false);
echo $this->EndTabHeaders();
// Display each tab's content
echo $this->StartTabContent();
echo $this->StartTab('toevoegen');
echo $this->CreateFormStart($id, 'process', $returnid);
echo $this->CreateInputHidden($id, "method", "insert");
echo $this->CreateInputText($id, "tag", "", "20");
echo $this->CreateInputSubmit($id, "submit", "Toevoegen");
echo $this->CreateFormEnd();
echo $this->EndTab();
echo $this->StartTab('verwijderen');
$values = array();
$values = $this->_Load_Tags();
echo $this->CreateFormStart($id, 'process', $returnid);
echo $this->CreateInputHidden($id, "method", "delete");
echo "<table>";
foreach ($values as $key => $value)
{
echo "<tr>";
echo "<td width='100px'>";
echo $value;
echo "</td>";
echo "<td>";
echo $this->CreateInputHidden($id, "id", $key);
echo $this->CreateInputSubmit($id, "submit", "Verwijderen");
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo $this->CreateFormEnd();
echo $this->EndTab();
echo $this->EndTabContent();
Code: Select all
if( !isset(cmsms()) ) exit;
if (isset($params['method']) || isset($params['meth']))
{
if ($params['method'] == "insert")
{
$tag = $params['tag'];
$insert_SQL = "Insert Into ins_tagcloud (tag) Values ('" . $tag . "')";
$insert_result = mysql_query($insert_SQL) or die (mysql_error());
$this->Redirect ($id, 'defaultadmin', $returnid);
}
elseif ($params['method'] == "delete")
{
$id = $params['id'];
$delete_SQL = "Delete From ins_tagcloud Where id = '" . $id . "'";
$delete_result = mysql_query($delete_SQL) or die (mysql_error());
$this->Redirect ($id, 'defaultadmin', $returnid);
}
}
else
{
$this->Redirect ($id, 'defaultadmin', $returnid);
}