vadim gavrilov wrote:
Nice, Any way of having the structure or if possible the code. I am just looking on what kind of structure and the way other developers use. And if that something better/convenient then what i use then i would like to adopt new ideas.

The code isn't finished, but I can share the interesting bits and the layout.

I based the layout off the new layout proposal.
Application
--controllers
--forms  (I use an action helper to load all my forms from this directory)
--layout
--models
--modules (each of these has the typical module structure of controller, models, views)
----admin
----forums
----frontsite (the marketing module)
--views
--bootstrap.php
--Initializer.php
config
data
--cache
--files
--locales
--logs
--uploads
docs
library
public
--js
--resources
test



Interesting code bits happen in the Initializer. The frontsite module is set when the URL hostname is different, so in routeShutdown I have to set the module. Also I need to play with phpbb url a bit to get right controller/action. routeShutdown becomes

   function routeShutdown(Zend_Controller_Request_Abstract $request) {
       $ini = Zend_Registry::get('ini');
if( $_SERVER['HTTP_HOST'] == $ini->frontsite && $request->getModuleName() == 'default'){
           $request->setModuleName('frontsite');
       }

       if($request->getModuleName() == 'forums'){
           // Need to fix it up if controller is *.php
           $phpExt = stripos($request->getControllerName(),'.php');
           if($phpExt){
               $action = substr($request->getControllerName(),0,$phpExt);
               $request->setActionName($action);
               $request->setControllerName('index');
           }
       }
   }

I also need to turn off view rendering in forums so the Forums_IndexController class has a preDispatch
class Forums_IndexController extends Zend_Controller_Action {

   function preDispatch() {
set_include_path(APP_PATH . 'application/modules/forums/models' . PATH_SEPARATOR . get_include_path()); define('PHPBB_ROOT_PATH', APP_PATH . 'application/modules/forums/models/');
   }

PHPBB_ROOT_PATH is needed by the phpbb3 package. It is used to set a variable that is used two different ways. First it is used in a lot of file exists and include statements which is what this define works well for. Next it is used in {phpbb_root_path} statements to construct a URL. Anyplace it used like that I just removed from the URL construction. phpbb3 is then installed under the models directory for this module and all the actions look like this.

   /**
    * The default action - show the home page
    */
   public function indexAction(){
       // phpbb3 needs some globals
global $phpEx, $phpbb_root_path, $user, $db, $auth, $template, $cache, $config;
       require_once 'index.php';
   }

   function styleAction() {
       // phpbb3 needs some globals
global $phpEx, $phpbb_root_path, $user, $db, $auth, $template, $cache, $config;
       require_once 'style.php';
   }




Reply via email to