Cập nhật:
Tìm thấy một cách khác cho trang bảo trì dịch:
https://github.com/OpenMage/magento-lts/blob/1.9.3.x/errors/ Processor.php # L160-L162
if (isset($_GET['skin'])) {
$this->_setSkin($_GET['skin']);
}
Trình xây dựng trang bảo trì tích lũy skintham số POST để thay đổi bố cục. Nó có vẻ là cách cố ý, nhưng nó không được ghi lại (chưa) ...
Thêm một số quy tắc viết lại để .htaccessthêm một skintham số vào URL của bạn. Ví dụ.
RewriteCond %{HTTP_HOST} ^french.example.com$
RewriteCond %{DOCUMENT_ROOT}/.maintenance.flag -f
RewriteCond %{QUERY_STRING} !(^|&)skin=french(&|$) [NC]
RewriteRule ^ %{REQUEST_URI}?skin=french[L]
Sao chép errors/defaultvàoerrors/french
- Thay đổi / dịch tập tin mẫu theo nhu cầu của bạn
Có thể hơi muộn, nhưng một giải pháp hoạt động tốt , không cần sao chép errorthư mục vào mọi thư mục con ...
"Nhược điểm":
- bạn phải chỉnh sửa ba tập tin cốt lõi. Để tránh các chỉnh sửa trong lõi càng nhiều càng tốt, tôi chỉ thay đổi bao gồm đường dẫn của các trang báo cáo / lỗi và mở rộng
processor.phpđể đọc một sửa đổi local.xml.
- nó vẫn yêu cầu các tệp mẫu cho mọi ngôn ngữ (hiện tại không có bản dịch - có thể sau này )
Thiết lập cơ bản
Multi-trang web đa cửa hàng thiết lập như thế này, chỉ differnce là tôi đã thiết lập MAGE_RUN_CODEtrong .htaccessthay vì index.php. Đối với tên miền đầu tiên, tôi không sử dụng RUN_CODEtất cả các tên miền khác ...
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule .* - [E=MAGE_RUN_CODE:website1]
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule .* - [E=MAGE_RUN_TYPE:website]
Ngoài các câu trả lời liên quan tôi đã phải thiết lập RewriteBasetrong .htaccessđể phù hợp với mục locale và chỉnh sửa index.phptrong en, frvà sự thay đổi
$maintenanceFile = 'maintenance.flag';
...
if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
đến
$maintenanceFile = '../maintenance.flag';
...
if (file_exists($maintenanceFile)) {
include_once '../errors/503.php';
exit;
}
Chỉnh sửa errors/404.php, 503.phpvàreport.php
Thay thế
require_once 'processor.php';
$processor = new Error_Processor();
với
require_once 'processor_multiwebsite.php';
$processor = new Error_Processor_Multiwebsite();
Và thêm nó vào 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;
}
}
}
}
local.xmlCấu trúc mới
Thay vì đặt <skin>ở cấp đầu tiên, hãy tìm trang web runcode / locale trước
<?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>
Mẫu
Thêm 503.phtml, ..., CSS vào thư mục phù hợp<runcode>-<locale>
default-default (Ngôn ngữ mặc định của tên miền thứ 1)
default-en
default-fr
website1-default (Ngôn ngữ mặc định của tên miền thứ 2)
- ...
Không có CSS / hình ảnh trùng lặp
- đặt các tệp CSS / hình ảnh cụ thể của trang web của bạn vào một thư mục và thêm
<skin_base>nút vàolocal.xml
- thay đổi TẤT CẢ các liên kết tĩnh trong
page.phtmlcác tệp từ tức là href="css/styles.css"thành<?php echo $this->getSkinBaseUrl('css/styles.css')?>