public function actionDelete($id = null) { try { $page = Page::findOneById($id); list($success, $count) = $page->delete(); } catch (\Nerd\DB\Exception $e) { $this->flash->set('warning', "You may not delete <em>{$page->title}</em>. It is a <strong>Nerd</strong> protected file."); $this->application->redirect(Url::site('/pages')); } if ($success and $count > 0) { $this->flash->set('success', "<em>{$page->title}</em> has been deleted."); } else { $this->flash->set('error', "<em>{$page->title}</em> could not be deleted."); } $this->application->redirect(Url::site('/pages')); }
<?php namespace Nerd; use Application\Flash; ?> <h2>Host <small><?php echo $site->host; ?> </small></h2> <?php echo Flash::info($flash->get('info')); echo Flash::success($flash->get('success')); echo Flash::warning($flash->get('warning')); echo Flash::error($flash->get('error')); ?> <a href="<?php echo Url::site('/sites'); ?> " class="btn">Back</a><?php
?> " class="btn btn-mini">View</a> <a href="<?php echo Url::site("/sites/update/{$site->id}"); ?> " class="btn btn-mini">Edit</a> <a href="<?php echo Url::site("/sites/delete/{$site->id}"); ?> " class="btn btn-mini btn-danger">Delete</a> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p>There are no results to display.</p> <?php } ?> <div class="form-actions"> <a href="<?php echo Url::site('/sites/create'); ?> " class="btn btn-primary">New Site</a> </div><?php
public function actionDelete($id = null) { try { $site = Site::findOneById($id); list($success, $count) = $site->delete(); } catch (\Nerd\DB\Exception $e) { $this->flash->set('warning', "There was a database error..."); $this->application->redirect(Url::site('/sites')); } if ($success and $count > 0) { $this->flash->set('success', "<strong>{$site->host}</strong> has been deleted."); } else { $this->flash->set('error', "<strong>{$site->host}</strong> could not be deleted."); } $this->application->redirect(Url::site('/sites')); }
<?php namespace Nerd; use Application\Flash; ?> <h2><?php echo $page->title; ?> <small><?php echo $page->uri; ?> </small></h2> <?php echo Flash::info($flash->get('info')); echo Flash::success($flash->get('success')); echo Flash::warning($flash->get('warning')); echo Flash::error($flash->get('error')); ?> <a href="<?php echo Url::site($lastSearch); ?> " class="btn">Back</a><?php