Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 959915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:06:00+00:00 2026-05-16T01:06:00+00:00

In my bootstrap, I detect the site the users on, then issue the layout

  • 0

In my bootstrap, I detect the site the users on, then issue the layout change and helper change. Essentially anything that is there by default is what the site falls back on if there is no per site version in /public/site/

However I cannot get the actual view to rely on a path a give it or a path in /public/site.

Here is my code so far:

protected function _initSite() {

        $this->bootstrap('db');
        $db             = $this->getPluginResource('db')->getDbAdapter();
        $site_domain    = strtolower($_SERVER['HTTP_HOST']);

        //site
        $query = $db->prepare("
            SELECT s.*, so.* 
            FROM Site AS s
            JOIN Site_Domain AS sd ON sd.site_id = s.id
            JOIN Site_Option AS so ON so.site_id = s.id 
            WHERE sd.domain = :site_domain AND s.enabled = '1'
            LIMIT 1
        ");
        $query->bindValue('site_domain', $site_domain);
        $query->execute();
        $site = $query->fetch(PDO::FETCH_OBJ);
        $query->closeCursor();

        if (empty($site)) {
            throw new exception('Unfortunately we were unable to load the site you requested via the domain you came to.');
        }

        //site definitions - we need to get away from defining global variables, so lazy
        define('SITE_ID', $site->id);

        //layout paths
        Zend_Layout::startMvc(array(
            'layout' => 'layout',
            'layoutPath' => array(
                APPLICATION_PATH.'/layouts/scripts/',
                PUBLIC_PATH.'/site/'.$site->id.'/layouts/scripts/'
            )
        ));



        $view = $this->getResource('view');
        //set site to view, we use alot of google anayltics code so
        $view->site = $site;
        //set title seperator
        $view->headTitle($site->title)->setSeparator(' - ');
        //add base path for layout overriding
        $view->addBasePath(APPLICATION_PATH.'/modules/:module/views/');
        //register view helper path
        $view->addHelperPath('My/View/Helper/', 'My_View_Helper_');

        //register partials fallback path
        $view->addScriptPath(APPLICATION_PATH.'/layouts/partials');
        //default partials path
        $view->addScriptPath(PUBLIC_PATH.'/site/'.$site->id.'/layouts/partials/');//the default helpers

        //bind objects to the registry
        Zend_Registry::set('config',    array('meta_description' => $site->meta_description, 'meta_keywords' => $site->meta_keywords));
        Zend_Registry::set('site',      $site);
        return $site;
    }

Essentially when landing on the site, Zend_View should check to see if /public/site/1/layouts/view/scripts/default/index/index.phtml exists and use it, if it doesn’t then use /application/modules/default/views/scripts/index/index.phtml and use it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:06:01+00:00Added an answer on May 16, 2026 at 1:06 am

    Okay so heres how I got it working:

    Bootstrap:

    protected function _initSite() {
    
        $this->bootstrap('db');
        $db             = $this->getPluginResource('db')->getDbAdapter();
        $site_domain    = strtolower($_SERVER['HTTP_HOST']);
    
        //site
        $query = $db->prepare("
            SELECT s.*, so.* 
            FROM Site AS s
            JOIN Site_Domain AS sd ON sd.site_id = s.id
            JOIN Site_Option AS so ON so.site_id = s.id 
            WHERE sd.domain = :site_domain AND s.enabled = '1'
            LIMIT 1
        ");
        $query->bindValue('site_domain', $site_domain);
        $query->execute();
        $site = $query->fetch(PDO::FETCH_OBJ);
        $query->closeCursor();
    
        if (empty($site)) {
            throw new exception('Unfortunately we were unable to load the site you requested via the domain you came to.');
        }
    
        //site definitions - we need to get away from defining global variables, so lazy
        define('SITE_ID', $site->id);
    
        //view helper
        $view = $this->getResource('view');
        $view->addHelperPath('My/View/Helper/', 'My_View_Helper_');
    
        //view plugin
        $front  = $this->getResource('FrontController');
        $plugin = new My_Controller_Plugin_View();
        $front->registerPlugin($plugin);
    
        Zend_Registry::set('config',    array('meta_description' => $site->meta_description, 'meta_keywords' => $site->meta_keywords));
        Zend_Registry::set('site',      $site);
        return $site;
    }
    

    Plugin:

    class My_Controller_Plugin_View extends Zend_Controller_Plugin_Abstract {
    
    
        public function routeShutdown(Zend_Controller_Request_Abstract $request) {
    
            $this->bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
            $view = $this->bootstrap->getResource('view');
            $site = Zend_Registry::get('site');
    
            //layout paths
            Zend_Layout::startMvc(array(
                'layout' => 'layout',
                'layoutPath' => array(
                    APPLICATION_PATH.'/layouts/scripts/',
                    PUBLIC_PATH.'/site/'.$site->id.'/layouts/scripts/'
                )
            ));
    
            $front = Zend_Controller_Front::getInstance();
            $request = $front->getRequest();
            $module = $request->getModuleName();
    
            //set site to view, we use alot of google anayltics code so
            $view->site = $site;
    
            //set title seperator
            $view->headTitle($site->title)->setSeparator(' - ');
    
            //add base path for layout overriding
            //$view->addBasePath(APPLICATION_PATH.'/modules/:module/views/');
    
            //register partials fallback path
            $view->setScriptPath(NULL);
            //$view->setScriptPath(array());
            $view->addBasePath(APPLICATION_PATH.'/modules/'.$module.'/views/');
            $view->addBasePath(PUBLIC_PATH.'/site/'.$site->id.'/layouts/templates/'.$module);
            $view->addScriptPath(APPLICATION_PATH.'/layouts/partials');
            $view->addScriptPath(PUBLIC_PATH.'/site/'.$site->id.'/layouts/partials/');
    
            //print_r($view);exit;
    
            $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
            //$viewRenderer->setViewBasePathSpec(PUBLIC_PATH.'/site/'.$site->id.'/layouts/templates/:module/')->initView();
    
        }
    
    
        public function preDispatch(Zend_Controller_Request_Abstract $request) {
    
        }
    
    }
    

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Twitter Bootstrap site reads as follows: The default and simple 940px-wide, centered layout
Twitter Bootstrap http://twitter.github.com/bootstrap/javascript.html#dropdown has a dropdown.js library (at http://twitter.github.com/bootstrap/1.4.0/bootstrap-dropdown.js )that will change the dropdown
We are using twitter bootstrap to do some redesign of our site. The issue
I'm loading javascript files in the bootstrap as usual, but there's a file that
Consider this route in bootstrap.php ... Route::set('crud', 'staff/<controller>(/<action>(/<id>))', array( 'controller' => '(activities|users|default-emails)', 'action' =>
Twitter Bootstrap has a form control that would glow on the borders when in
I'm using Bootstrap on a web app that has some pages that contain iframes.
I am using the Bootstrap CSS framework that has this: .dropdown-menu { left: 0;
I make a menu with Zend_Navigation. The trouble is that I detect a few
Bootstrap css uses the following: !function( $ ) { }( window.jQuery ) That's different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.