2

I am building a template right now for a client that wants to have multiple microsites and one master site under one instance of joomla. I'm building it in Joomla, because that is what I know, so please don't suggest another CMS, and yes I know Drupal supports this inherently! So here is the skinny. Right now my template looks for a domain name from the template params and then compares that to the base URI and then sets the variables to be used throughout the templates. So the code looks like this...

 //multisite configuration - determines which template params and menu module to display depending on the base URL
$url = JURI::base();
$primary = 'http://'.$this->params->get('site-domain').'/';
$sub1= 'http://'.$this->params->get('domain1-domain').'/';
$sub2= 'http://'.$this->params->get('domain2-domain').'/';
$sub3= 'http://'.$this->params->get('domain3-domain').'/';
$sub4= 'http://'.$this->params->get('domain4-domain').'/';
$sub5= 'http://'.$this->params->get('domain5-domain').'/';
if($url == $primary):
    $logo = $this->params->get('logo');
    $title = $this->params->get('site-title');
    $slogan = $this->params->get('site-slogan');
    $menu = '<jdoc:include type="modules" name="menu" />';
elseif($url == $sub1):
    $logo = $this->params->get('domain1-logo');
    $title = $this->params->get('domain1-title');
    $slogan = $this->params->get('domain1-slogan');
    $menu = '<jdoc:include type="modules" name="menu-1" />';
elseif($url == $sub2):
    $logo = $this->params->get('domain2-logo');
    $title = $this->params->get('domain2-title');
    $slogan = $this->params->get('domain2-slogan');
    $menu = '<jdoc:include type="modules" name="menu-2" />';
elseif($url == $sub3):
    $logo = $this->params->get('domain3-logo');
    $title = $this->params->get('domain3-title');
    $slogan = $this->params->get('domain3-slogan');
    $menu = '<jdoc:include type="modules" name="menu-3" />';
elseif($url == $sub4):
    $logo = $this->params->get('domain4-logo');
    $title = $this->params->get('domain4-title');
    $slogan = $this->params->get('domain4-slogan');
    $menu = '<jdoc:include type="modules" name="menu-4" />';
elseif($url == $sub5):
    $logo = $this->params->get('domain5-logo');
    $title = $this->params->get('domain5-title');
    $slogan = $this->params->get('domain5-slogan');
    $menu = '<jdoc:include type="modules" name="menu-5" />';
endif;

So now what i need to do is build a template parameter that determines what menu item ID is default menu item and then do a PHP header redirect. Since Joomla does not support multiple defaults, I need a work around to generate the necessary redirect URL. I am thinking by menu item id or alias as I dont want to be limited to a category or article type display. Unfortunately solving this is where my knowledge of PHP and Joomla fall short. Any help would be great.

Thanks Sandra :)

1 Answer 1

3

You could instead use an extension like Virtual Domains, which allows you to associate different domains with different default menu items. Then, you could use standard Joomla templates and assign them on a menu basis.

1
  • 1
    Yes, I do realize that this is not the answer you were looking for, but implementing a multi-domain type solution within a template is not optimal. Ideally, you would do this after the request is received, but before it is routed. You are attempting to do this much later in the execution cycle, during the rendering process. A solution like the one I suggested will do this in a more appropriate point in the execution cycle, and prevent you from having to reinvent the wheel. You could use template styles to implement varied looks of the template per each domain's default menu item. Commented Jun 24, 2013 at 1:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.