Skip to main content
7 of 10
added 5 characters in body
sv3n
  • 11.7k
  • 7
  • 41
  • 73

##Update:

Found another way for translated maintenance page:

  1. In you .htaccess add an rewrite rule that appends a skin parameter to your URL. Eg.

    RewriteCond %{HTTP_HOST} ^french.example.com$
    RewriteCond %{DOCUMENT_ROOT}/.maintenance.flag -f
    RewriteCond %{QUERY_STRING} !(^|&)skin=french(&|$) [NC]
    RewriteRule ^ %{REQUEST_URI}?skin=french[L]
    
  2. Copy errors/default to errors/french

  3. Change/translate template files to your needs


Maybe bit late, but a good working solution, without copying error directory to every subfolder ...

"Downsides":

  • you have to edit three core files. To avoid edits in core as much as possible I just changed include path of error/report pages and extended processor.php to read a modified local.xml.
  • it still requires template files for every language (no translation at the moment - maybe later)

Basic setup

Multi-website multi-store set-up like this, only differnce is that I've set MAGE_RUN_CODE in .htaccess instead of index.php. For 1st domain I use no RUN_CODE all others it looks like ...

RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule .* - [E=MAGE_RUN_CODE:website1]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule .* - [E=MAGE_RUN_TYPE:website]

In addition to the linked answer I had to set RewriteBase in .htaccess to match locale directory and edit index.php in en, fr and change

$maintenanceFile = 'maintenance.flag';
...
if (file_exists($maintenanceFile)) {
    include_once dirname(__FILE__) . '/errors/503.php';
    exit;
}

to

$maintenanceFile = '../maintenance.flag';
...
if (file_exists($maintenanceFile)) {
    include_once '../errors/503.php';
    exit;
}

Edit errors/404.php, 503.php and report.php

Replace

require_once 'processor.php';
$processor = new Error_Processor();

with

require_once 'processor_multiwebsite.php';
$processor = new Error_Processor_Multiwebsite();

And add this to errors/processor_multiwebsite.php

<?php
require_once 'processor.php';
class Error_Processor_Multiwebsite extends Error_Processor
{
    const DEFAULT_RUNCODE = 'default';
    const DEFAULT_LOCALE = 'default';
    
    /**
     * Magento run code
     *
     * @var string
    */
    protected $_runCode;

    /**
     * Magento run code
     *
     * @var string
    */
    protected $_locale;

    public function __construct()
    {
        $this->_runCode = self::DEFAULT_RUNCODE;
        if (isset($_SERVER['MAGE_RUN_CODE'])) {
            $this->_runCode = $_SERVER['MAGE_RUN_CODE'];
        }

        $this->_locale = self::DEFAULT_LOCALE;
        $path = array_filter(explode('/', str_replace('index.php', '', $_SERVER['SCRIPT_NAME'])));
        if (end($path)) {
            $this->_locale = end($path);
        }

        parent::__construct();
    }

    /**
     * Retrieve skin URL
     *
     * @return string
     */
    public function getSkinUrl()
    {
        $baseUrl = str_replace($this->_locale . '/', '', $this->getBaseUrl());
        return $baseUrl . self::ERROR_DIR. '/' . $this->_config->skin . '/';
    }


    /**
     * Retrieve skin base URL
     *
     * @return string
     */
    public function getSkinBaseUrl($file)
    {
        return $this->_config->skin_base ? "../{$this->_config->skin_base}/{$file}" : $file;
    }
    
    /**
     * Prepare config data
     */
    protected function _prepareConfig()
    {
        parent::_prepareConfig();

        $local  = $this->_loadXml(self::MAGE_ERRORS_LOCAL_XML);
        if (!is_null($local)) {
            if ((string)$local->{$this->_runCode}->{$this->_locale}->skin) {
                $this->_config->skin = (string)$local->{$this->_runCode}->{$this->_locale}->skin;
            }
            # add skin base URL
            if ((string)$local->{$this->_runCode}->{$this->_locale}->skin_base) {
                $this->_config->skin_base = (string)$local->{$this->_runCode}->{$this->_locale}->skin_base;
            }
        }
    }
}

New local.xml structure

Instead of setting<skin> at the first level look for websites runcode/locale first

<?xml version="1.0"?>
<config>
    <!-- 1st domain w/o runcode -->
    <default>
        <!-- no locale sub dir -->
        <default>
            <skin>default-default</skin>
            ...
        </default>
        <en>
            <skin>default-en</skin>
            <skin_base>default-default</skin_base>
            ...
        </en>
        <fr>
            <skin>default-fr</skin>
            <skin_base>default-default</skin_base>
            ...
        </fr>
    </default>
    <!-- runcode website1 -->
    <website1>
        <!-- no locale sub dir -->
        <default>
            <skin>website1-default</skin>
            ...
        </default>
        ...
    </website1>
</config>

Templates

Add 503.phtml, ... , CSS to directories matching <runcode>-<locale>

  • default-default (1st domain default language)
  • default-en
  • default-fr
  • website1-default (2nd domain default language)
  • ...

No duplicate CSS/images

  • put your website specific CSS/images files into one directory and add <skin_base> node to local.xml
  • change ALL static links in page.phtml files from i.e. href="css/styles.css" to <?php echo $this->getSkinBaseUrl('css/styles.css')?>
sv3n
  • 11.7k
  • 7
  • 41
  • 73