Hello,
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.