Home > php教程 > php手册 > body text

Drupal系列网站设置文件settings.php包含共用的部分

WBOY
Release: 2016-06-06 20:11:03
Original
1181 people have browsed it

以前在设置MediaWiki网站的时候,是把一些共用的修改放在CommonSettings.php中,然后LocalSettings.php中最后加入一行: require_once( "/usr/local/apache2/htdocs/common/CommonSettings.php" ); 就可以让一系列的网站都共用CommonSettings.php这个文件中

  以前在设置MediaWiki网站的时候,是把一些共用的修改放在CommonSettings.php中,然后LocalSettings.php中最后加入一行:

require_once( "/usr/local/apache2/htdocs/common/CommonSettings.php" );
Copy after login

  就可以让一系列的网站都共用CommonSettings.php这个文件中的设置,比较简单、方便,我们一直在采用。

  在Drupal的网站中,因为需要在settings.php中做的修改不算多,所以以前就没有像上面那样设置,只是在各个站的settings.php中单独修改需要修改的内容。

  近期因为做多语言的系列网站需要在settings.php中修改site name,逐个修改很麻烦,就想到调用统一的common.php,然后以后的修改就只需要在这一个文件就可以了,这个办法也很简单,在各个站的settings.php最后一行加入:

require_once( "/var/www/html/example.com/sites/common.php" );
Copy after login

  这个common.php中可以包含各种设置、判断、翻译等。

  我们以前的settings.php中一般只是加入了一条判断手机版的语句,例如:

if (substr($path,0,3)=='/m/') $conf['theme_default'] = 'mobile';
Copy after login

  可以把这一句复制到common.php,并加入更多的其它设置语句。原来的settings.php可以批量修改,用到的linux shell语句示例如下:

find /var/www/html/example.com/sites -maxdepth 2 -name 'settings.php' | xargs perl -pi -e 's|.*substr.*theme_default.*mobile.*|require_once( "/var/www/html/example.com/sites/common.php" );|g'
Copy after login

?

自由标签:

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!