跳转到主要内容
xieyanxy9 提交于 30 November 2012

原文链接:drupal.org/node/195435

维护页是什么?

网站设置为离线模式或的网站是因为技术问题,如数据库故障无法运行时,将使用维护页。您可以启用此模式从"管理 > 站点配置 > 网站维护"。这种模式也会触发数据库出现故障期间。默认情况下,核心主题 Minnelli 用于在此模式下即使选择了另一个主题。不过,您可能想包括维护页从您自己的网站内。

重写中 Drupal 模板文件

maintenance-page--offline.tpl.php file which exists in Drupal core, that you can duplicate into your own theme.">在 Drupal 中创建自定义主题是重写现有模板的做法 (。 tpl.php) 文件。您可以找到包含的核心分布的模板文件,可以将这些文件复制到主题文件夹中,或者创建新文件的名称相同。Drupal 将首先选择您的主题模板文件之前的核心。这种方式,您可以重写默认的模板。maintenance-page--offline.tpl.php file which exists in Drupal core, that you can duplicate into your own theme." lang="zh-CHS">例如,有maintenance-page--offline.tpl.php在 Drupal 的核心,这可以将其复制到您自己的主题中存在的文件。

maintenance-page.tpl.php doesn't exist in core, but you can create a file with that name and Drupal will recognize it.">有时您可以使用模板的建议,这意味着文件并不存在与 Drupal 的示例,但如果您将文件包含建议的名称,Drupal 会把它捡起来。maintenance-page.tpl.php doesn't exist in core, but you can create a file with that name and Drupal will recognize it." lang="zh-CHS">例如maintenance-page.tpl.php并不存在于核心,但您可以创建具有该名称的文件和 Drupal 会将对其进行识别。

page.tpl.php twice and name them:">在这种情况下有两个维护页面文件,您可以创建。page.tpl.php twice and name them:" lang="zh-CHS">您可以重复你的主题page.tpl.php的两倍和它们命名为:

  1. maintenance-page.tpl.php: This file controls the page that is displayed when the site is in "maintenance mode" but the database connection and database are still functioning correctly." lang="zh-CHS">maintenance-page.tpl.php: 此文件控制的网站是在"维护模式"中,但数据库连接和数据库是否仍能正常运行时,将显示的页面。
  2. maintenance-page--offline.tpl.php: This file controls the page that is displayed when Drupal cannot access the database (for whatever reason)." lang="zh-CHS">maintenance-page--offline.tpl.php: 此文件控制 (不管出于什么原因),Drupal 无法访问数据库时,将显示的页面。

第 1 步: 重写的维护页面模板

page.tpl.php and rename it to maintenance-page.tpl.php or copy the template located in modules/system/maintenance-page.tpl.php to your theme and edit so it matches the rest of your site." lang="zh-CHS">您主要的page.tpl.php和重命名为maintenance-page.tpl.php或复制位于modules/system/maintenance-page.tpl.php到你的主题的模板和编辑,使它与您的网站的其余部分相匹配。

步骤 2: 在 settings.php 文件中的指示

settings.php file, which is usually located at sites/default or sites/yourdomain.com (if you are on a multi-site installation).">在数据库出现故障,所以这不访问数据库的权限可以操作此方法,也必须在配置文件中表示您维护页面设置。settings.php file, which is usually located at sites/default or sites/yourdomain.com (if you are on a multi-site installation)." lang="zh-CHS">在settings.php文件中,这是通常位于sites/defaultsites/yourdomain.com(如果您是在多站点安装) 指定您维护页。

选项 1

settings.php file, enable the $conf variable with the internal name of your theme:" lang="zh-CHS">在settings.php文件中,启用$conf变量与你的主题的内部名称:

<?php  $conf['maintenance_theme'] = 'themeName';?>

选项 2

settings.php file, numerous configurations are disabled with a # (<EM>hash</EM>) symbol at the start of the line. You can remove the # symbol at the start of the line to uncomment and enable that configuration.">settings.php file, numerous configurations are disabled with a # (<EM>hash</EM>) symbol at the start of the line. " lang="zh-CHS">在settings.php文件中,无数的配置被禁用以 (哈希) # 符号开头的行。您可以删除 # 符号开头的行,请取消注释,使该配置。

settings.php file, you can also uncomment the relevant lines in settings.php. In that case, you have to uncomment 3 separate lines:">settings.php file, you can also uncomment the relevant lines in settings.php. " lang="zh-CHS">因此,而不是添加到settings.php文件与上面的选项 1 行,您也可以取消settings.php中的相关行。在这种情况下,您必须取消注释 3 单独的行:

  • # $conf = array(" lang="zh-CHS">数组声明 (# $conf = array()
  • # 'maintenance_theme' =&gt; 'minnelli'," lang="zh-CHS">维修主题设置 (# 'maintenance_theme' => 'minnelli',)
  • 关闭括号 (# );)

通过设置站点到离线模式来验证所做的更改,然后注销。

要考虑到数据库失败,请尝试关闭您的数据库。与db_is_active,应首先检查取决于数据库的任何函数调用。此外可以从模板使用变量 $db_is_active。

禁用您的数据库的替代方法,作为强制数据库连接失败。能找到这两种方法的例子在这里.

步骤 3: 创建在数据库出现故障的维修脱机页

page.tpl.php file and rename it maintenance-page--offline.tpl.php. Change the $content variable with your custom message. Note, this template file is a <A data-cke-saved-href="http://www.microsofttranslator.com/bv.aspx?from=&amp;to=zh-CHS&amp;a=http%3A%2F%2Fdrupal.org%2Fnode%2F223440" href="http://www.microsofttranslator.com/bv.aspx?from=&amp;to=zh-CHS&amp;a=http%3A%2F%2Fdrupal.org%2Fnode%2F223440" rel=nofollow target=_top>template suggestion</A> based on maintenance-page.tpl.php so they both need to exist in the same folder.">page.tpl.php file and rename it maintenance-page--offline.tpl.php. " lang="zh-CHS">若要防止从出现的数据库连接的警告,将page.tpl.php文件复制和重命名它maintenance-page--offline.tpl.php。$content variable with your custom message. " lang="zh-CHS">更改在您的自定义消息的$content变量。maintenance-page.tpl.php so they both need to exist in the same folder." lang="zh-CHS">请注意,此模板文件是基于maintenance-page.tpl.php,所以他们都需要相同的文件夹中存在一个模板的建议

maintenance-page--offline.tpl.php, you might also want to set the following variables detailed in step 4." lang="zh-CHS">顶部的maintenance-page--offline.tpl.php,您可能还需要设置以下详细的步骤 4 中的变量。

步骤 4: 硬编码网站设置

在此模式下,您的数据库是不可访问,因此一些有关您的站点的关键设置不可用。如果您想要使用相同的主题和其他设置的站点通常会使用此页,您必须通过使用硬编码的值复制这些设置。

maintenance-page--offline.tpl.php file:" lang="zh-CHS">复制到这些变量maintenance-page--offline.tpl.php文件:

  • $head_title - the value used in the HTML &lt;title&gt; tag. Defaults to "Site off-line | Drupal"">$head_title - the value used in the HTML &lt;title&gt; tag. " lang="zh-CHS">$head_title- <title>的 HTML 标记中使用的值。默认为"离线网站 |"Drupal
  • $site_name - the value used in the page's &lt;h1&gt; tag. Defaults to "Drupal". If "Site name" is turned off in your theme configuration, then you'll want to clear this variable (see example below).">$site_name - the value used in the page's &lt;h1&gt; tag. " lang="zh-CHS">$site_name- <h1>页的标记中使用的值。默认值为"Drupal"。如果"站点名称"处于关闭状态,在您的主题配置,那么你就会想要清除此变量 (请参阅下面的示例)。
  • $logo - if you're using a custom logo override in the theme settings. Use the full path of the custom logo, relative to the base directory of the Drupal installation. If you used the standard override upload function in the theme configuration for your custom logo, your logo will be stored in sites/all/files/ (see example below).">$logo - if you're using a custom logo override in the theme settings. " lang="zh-CHS">$logo-如果您使用的自定义徽标中的主题设置重写。使用自定义徽标,相对于 Drupal 安装的基目录的完整的路径。sites/all/files/ (see example below)." lang="zh-CHS">如果您使用的标准重写上传功能主题配置中用于自定义徽标,您的徽标将存储在sites/all/files/(请参阅下面的示例)。
  • $site_slogan - your site's slogan. If "Site slogan" is turned off in your theme configuration but you still have a site slogan defined in Site Information, then you'll want to clear this variable (see example below).">$site_slogan - your site's slogan. " lang="zh-CHS">$site_slogan-您的网站的口号。如果"网站口号"处于关闭状态,您的主题配置中,但您仍有界定的网站信息,网站口号则要清除此变量 (请参阅下面的示例)。

maintenance-page--offline.tpl.php" lang="zh-CHS">示例添加顶部的maintenance-page--offline.tpl.php:

<?php  $head_title = 'mysite.com :: Site-offline';  $logo = 'sites/all/files/customLogo.png';  // If your theme is set to display the site name, uncomment this line and replace the value:  // $site_name = 'Your Site Name';  // If your theme is set to *not* display the site name, uncomment this line:  unset($site_name);  // If your theme is set to display the site slogan, uncomment this line and replace the value:  $site_slogan = 'My Site Slogan';  // If your theme is set to *not* display the site slogan, uncomment this line:  // unset($site_slogan);  // Main message. Note HTML markup.  $content = '<p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p><hr /><p>If you are the maintainer of this site, please check your database settings.</p>';?>

maintenance.css file is included in this mode. It is located in modules/system/maintenance.css. You can override this file with the instructions provided in the <A data-cke-saved-href="http://www.microsofttranslator.com/bv.aspx?from=&amp;to=zh-CHS&amp;a=http%3A%2F%2Fdrupal.org%2Fnode%2F171209%23styles-override-module" href="http://www.microsofttranslator.com/bv.aspx?from=&amp;to=zh-CHS&amp;a=http%3A%2F%2Fdrupal.org%2Fnode%2F171209%23styles-override-module" rel=nofollow target=_top>style sheets section</A>">maintenance.css file is included in this mode. " lang="zh-CHS">maintenance.css文件包含在这种模式。modules/system/maintenance.css. " lang="zh-CHS">它位于modules/system/maintenance.css。您可以覆盖此文件与样式表一节中提供的说明.