Jose Diaz-Gonzalez is a developer living in New York City. He currently works at SeatGeek

About

Conditional Loading of Helpers

php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
class TumblesController extends TumbleAppController {

   var $name = 'Tumbles';
   function beforeRender() {
       parent::beforeRender()
       $this->_configureHelpers($this->params['action']);
   }
/**
 * Configures the helpers for the current action
 *
 * @author Jose Diaz-Gonzalez
 */
  function _configureHelpers($action) {
      switch ($action) {
          case 'index' :
              $this->helpers[] = 'Text';
              $this->helpers[] = 'Time';
              break;
          case 'view' :
              $this->helpers[] = 'HtmlCache.HtmlCache';
              $this->helpers[] = 'Text';
              $this->helpers[] = 'Time';
              break;
          case 'admin_add' :
              $this->helpers[] = 'Tagging.Tagging';
              $this->helpers = array_merge($this->helpers, array('Wysiwyg.Wysiwyg' => array('editor' => Configure::read('AppSettings.application.editor'))));
              break;
          case 'admin_preview' :
              $this->helpers = array_merge($this->helpers, array('Wysiwyg.Wysiwyg' => array('editor' => Configure::read('AppSettings.application.editor'))));
              break;
      }
  }
}
?>
0 Responses. Add Yours!

Discussion

blog comments powered by Disqus