Advertisement
Guest User

Untitled

a guest
May 5th, 2012
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.95 KB | None | 0 0
  1. <?php
  2.         //create a new view renderer if not exists
  3.         $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
  4.         if (null === $viewRenderer->view)
  5.         {
  6.             $viewRenderer->initView();
  7.         }
  8.         $view = $viewRenderer->view;
  9.        
  10.         //generate the file paths
  11.         $module_path = APP_DIR . DS . 'modules' . DS . $module . DS . 'views';
  12.         $module_file = $module_path . DS . 'scripts' . DS . $controller . DS . $action . '.phtml';
  13.        
  14.         $template_path = ROOT_DIR . DS . 'templates' . DS . $template . DS . 'views' . DS . $module;
  15.         $template_file = $template_path . DS . 'scripts' . DS . $controller . DS . $action . '.phtml';
  16.        
  17.         //set the script path to the right template
  18.         if (file_exists( realpath($template_file) ))
  19.         {
  20.             $view->setScriptPath( realpath($template_path . DS . 'scripts') );
  21.            
  22.             //add the helper path
  23.             if (file_exists($template_path . DS . 'helpers'))
  24.             {
  25.                 $view->addHelperPath($template_path . DS . 'helpers', $module . '_View_Helper_');
  26.             }
  27.         } else if (file_exists( realpath($module_file) ))
  28.         {
  29.             $view->setScriptPath( realpath($module_path . DS . 'scripts') );
  30.            
  31.             //add the helper path
  32.             if (file_exists($module_path . DS . 'helpers'))
  33.             {
  34.                 $view->addHelperPath($template_path . DS . 'helpers', $module . '_View_Helper_');
  35.             }
  36.         }
  37.        
  38.         echo '<pre>';
  39.         var_dump( realpath($template_file) );
  40.         var_dump( realpath($module_file) );
  41.         var_dump( realpath($template_path . DS . 'scripts' . DS) );
  42.         var_dump( realpath($module_path . DS . 'scripts' . DS) );
  43.         var_dump( file_exists( realpath($template_file) ) );
  44.         var_dump( file_exists( realpath($module_file) ) );
  45.         echo '</pre>';
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement