I'm not sure if this is the best way to do it, but it seems to be.
Here's the change to the updated url.php create function:
Code: Select all
function create($server, $controller, $action = NULL, $query = array()) {
$link = 'controller=' . $controller;
$wrapWithConfirmDeleteJS = false;
if ($action) {
if ($action == 'delete'){
$wrapWithConfirmDeleteJS = TRUE;
$link .= '&action=' . $action;
}else {
$link .= '&action=' . $action;
}
}
foreach ($query as $key => $value) {
if ($value) {
$link .= '&' . $key . '=' . urlencode($value);
}
}
if (isset($this->data[$link])) {
$link = $this->data[$link];
} else {
$link = 'index.php?' . $link;
}
if ($wrapWithConfirmDeleteJS){
$delete = ($link);
return ("if (confirm('Are you sure you want to permanently delete this ". $controller . "?')) { location='" . $delete . "'; } else { location='" . str_replace('delete', 'update', $delete) . "'; }");
}else{
$href = ($link);
return ($href);
}
}
Then, the last step is to make the following change to the list.tpl file in 'admin -> template -> default (or whatever) -> content':
Code: Select all
<td class="<?php echo $cell['align']; ?>"><?php foreach ($cell['action'] as $action) { ?>
<?php if ($action['text'] == 'Delete') { ?>
<a href="<?php echo($_SERVER['REQUEST_URI']); ?>" onclick="<?php echo $action['href']; ?>"><img src="template/default/image/<?php echo $action['icon']; ?>" alt="<?php echo $action['text']; ?>" title="<?php echo $action['text']; ?>" class="png" /></a>
<?php } else { ?>
<a href="<?php echo $action['href']; ?>"><img src="template/default/image/<?php echo $action['icon']; ?>" alt="<?php echo $action['text']; ?>" title="<?php echo $action['text']; ?>" class="png" /></a>
<?php } ?>
<?php } ?></td>
Cheers,
Dave