~~~~~~~~~~~~~~~
- A Newsletter system which integrates into existing multi-language
site. Currently the site consists in German and English version. Italian and
Spanish versions are planned.
2. Issues
~~~~~~~~~
- PHPList is relatively easy to integrate into an existing site. But for
multi-language support one would have to set up a new PHPList instance for
every new language. Dynamic front end language switch is however possible with
some coding. See 4. Multi-language support for details.
- Not all messages where translatable. See
- http://mantis.tincan.co.uk/view.php?id=6405
- http://mantis.tincan.co.uk/view.php?id=6406
- http://mantis.tincan.co.uk/view.php?id=6407
3. Integrate PHPList into your own site
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- We are using a simple framework for our site. Basically we setup a rather
static header, navigation and a footer. Depending on a $_GET variable we then
include a content page. For getting the multi-language requirement met we also
set a language variable with default to German.
Language settings:
- Code: Select all
if (isset($_GET['lang']) && $_GET['lang'] == 'en') {
$lang = '_en';
} else {
$lang = '';
}
Include content page:
- Code: Select all
if (isset($_GET['link'])) {
switch ($_GET['link']) {
case 'lb':
require_once "laptopbattle$lang.php";
break;
case 'news':
require_once "news_lb$lang.php";
break;
If someone points to http://example.com/?link=lb we include
laptopbattle.php
If someone points to http://example.com/?link=lb&lang=en we include
laptopbattle_en.php
With this framework, including PHPList's subscription page is easy:
- Code: Select all
if (isset($_GET['link'])) {
switch ($_GET['link']) {
// ...
case 'join':
require_once "join_lb$lang.php";
break;
case 'newsletter':
// Including PHPList by setting proper $_GET variables
if ($lang == '') {
$_GET['language_module'] = 'german.inc';
// id is the ID of the list to subcribe
// Each list can have it's custom fields (called
// attributes in PHPList) like country, name, age, ...
// Each custom field has it's translation.
$_GET['id'] = 1;
} else if ($lang == '_en') {
$_GET['language_module'] = 'english.inc';
$_GET['id'] = 2;
}
// Default is the subscription form
if (!isset($_GET['p'])) {
$_GET['p'] = 'subscribe';
}
require_once 'lists/index.php';
break;
case 'faq':
require_once "faq_lb$lang.php";
break;
// ...
With this approach you have to check, that you have no $_GET variable name
clashes. PHPList uses at least $_GET['p'] and $_GET['id']. On our site we do
not use this variables, so no variable name clashes where experienced.
If someone points to http://example.com/?link=newsletter, we include
lists/index.php
This is the front end entry point of PHPList. To get it running one has to pass
the required paramter $_GET['id']. A German subscription page was created
with the id 1 and an English subscription page with id of 2. Depending on our
current language ($lang) we set $_GET['id']. If no other action was set, we
set the default action "subcribe". After the variables are set, we then
inlcude the front end entry page of PHPList (lists/index.php)
Note that setting $_GET['language_module'] has no effect with standard
installation of PHPList. To get dynamic front end language switch working leads
to our next point.
4. Multi-language support
~~~~~~~~~~~~~~~~~~~~~~~~~
To get dynamic front end multi-language support one has to add following lines
to lists/index.php near the top:
- Code: Select all
// Around line 27 in PHPList 2.10.2 lists/index.php
// Added for dynamic language support (Hakan Kuecuekyilmaz)
if (isset($_GET['language_module'])) {
$GLOBALS['language_module'] = $_GET['language_module'];
}
require_once dirname(__FILE__) .'/admin/commonlib/lib/magic_quotes.php';
require_once dirname(__FILE__) .'/admin/init.php';
With this small modification, dynamic front end multi-language supports
works. Before one includes lists/index.php he can set $_GET['language_module']
to the desired <language>.inc file.
5. Examples
~~~~~~~~
German front end:
http://laptopbattle-mannheim.de/?link=newsletter
English front end:
http://laptopbattle-mannheim.de/?link=newsletter&lang=en
--
$Id: phplist_integration.txt 231 2006-05-22 06:54:29Z hakan $
Hakan Kuecuekyilmaz <hakan>, 2006-05-22