07.18 php saved
Martz
Tags add more
bake  
Note
Martz did not leave a note
  1. <?php
  2. class TagsController extends AppController {
  3.  
  4.         var $name = 'Tags';
  5.         var $helpers = array('Html', 'Form');
  6.  
  7.         function index() {
  8.                 $this->Tag->recursive = 0;
  9.                 $this->set('tags', $this->paginate());
  10.         }
  11.  
  12.         function add() {
  13.                 if (!empty($this->data)) {
  14.                         $this->Tag->create();
  15.                         if ($this->Tag->save($this->data)) {
  16.                                 $this->Session->setFlash(__('The Tag has been saved', true));
  17.                                 $this->redirect(array('action'=>'index'));
  18.                         } else {
  19.                                 $this->Session->setFlash(__('The Tag could not be saved. Please, try again.', true));
  20.                         }
  21.                 }
  22.                 $products = $this->Tag->Product->find('list');
  23.                 $this->set(compact('products'));
  24.         }
  25.  
  26.         function edit($id = null) {
  27.                 if (!$id && empty($this->data)) {
  28.                         $this->Session->setFlash(__('Invalid Tag', true));
  29.                         $this->redirect(array('action'=>'index'));
  30.                 }
  31.                 if (!empty($this->data)) {
  32.                         if ($this->Tag->save($this->data)) {
  33.                                 $this->Session->setFlash(__('The Tag has been saved', true));
  34.                                 $this->redirect(array('action'=>'index'));
  35.                         } else {
  36.                                 $this->Session->setFlash(__('The Tag could not be saved. Please, try again.', true));
  37.                         }
  38.                 }
  39.                 if (empty($this->data)) {
  40.                         $this->data = $this->Tag->read(null, $id);
  41.                 }
  42.                 $products = $this->Tag->Product->find('list');
  43.                 $this->set(compact('products'));
  44.         }
  45.  
  46.  
  47.  
  48.  
  49.  
  50. ***************** VIEW FILES **********************
  51. <div class="settings form">
  52. <?php echo $form->create('Setting');?>
  53.         <fieldset>
  54.                 <legend><?php __('Edit Setting');?></legend>
  55.         <?php
  56.                 echo $form->input('id');
  57.                 echo $form->input('name');
  58.                 echo $form->input('key');
  59.                 echo $form->input('description');
  60.                 echo $form->input('value');
  61.         ?>
  62.         </fieldset>
  63. <?php echo $form->end('Submit');?>
  64. </div>
  65. <div class="actions">
  66.         <ul>
  67.                 <li><?php echo $html->link(__('Delete', true), array('action'=>'delete', $form->value('Setting.id')), null, sprintf(__('Are you sure you wan$
  68.                 <li><?php echo $html->link(__('List Settings', true), array('action'=>'index'));?></li>
  69.                 <li><?php echo $html->link(__('List Attachments', true), array('controller'=> 'attachments', 'action'=>'index')); ?> </li>
  70.                 <li><?php echo $html->link(__('New Thumb', true), array('controller'=> 'attachments', 'action'=>'add')); ?> </li>
  71.         </ul>
  72. </div>
  73.  
Parsed in 0.209 seconds, using GeSHi 1.0.7.14

Modify this Paste