| 1 |
********************************************************************
|
| 2 |
D R U P A L M O D U L E
|
| 3 |
********************************************************************
|
| 4 |
Name: Page lang module
|
| 5 |
Version: 0.1
|
| 6 |
Author: Robert Douglass
|
| 7 |
Email: rob ad robshouse dot net
|
| 8 |
Last update: February 21, 2006
|
| 9 |
Drupal: 4.7
|
| 10 |
|
| 11 |
********************************************************************
|
| 12 |
DESCRIPTION:
|
| 13 |
|
| 14 |
* This module gives you control over the language of page. It gives you the chance
|
| 15 |
* to provide templates for how the lang should be structured, and on node
|
| 16 |
* pages, gives you the chance to specify the tag xhtml rather than defaulting
|
| 17 |
* to the site. This module is the same than page_title, but changes another thinks.
|
| 18 |
|
| 19 |
********************************************************************
|
| 20 |
PERMISSIONS:
|
| 21 |
|
| 22 |
This module defines the "set page language" permission. This permission determines
|
| 23 |
whether a user will se the "Page lang" field on node edit forms.
|
| 24 |
|
| 25 |
********************************************************************
|
| 26 |
SYSTEM REQUIREMENTS:
|
| 27 |
|
| 28 |
Drupal: 4.7
|
| 29 |
|
| 30 |
********************************************************************
|
| 31 |
INSTALLATION:
|
| 32 |
|
| 33 |
1. Place the entire page_title directory into your Drupal modules/
|
| 34 |
directory.
|
| 35 |
|
| 36 |
|
| 37 |
2. Enable this module by navigating to:
|
| 38 |
|
| 39 |
administer > modules
|
| 40 |
|
| 41 |
At this point the Drupal install system will attempt to create the database
|
| 42 |
table page_lang. You should see a message confirming success or
|
| 43 |
proclaiming failure. If the database table creation did not succeed,
|
| 44 |
you will need to manually add the following table definition to your
|
| 45 |
database:
|
| 46 |
|
| 47 |
CREATE TABLE `page_lang` (
|
| 48 |
`nid` INT NOT NULL ,
|
| 49 |
`page_title` VARCHAR( 128 ) NOT NULL ,
|
| 50 |
PRIMARY KEY ( `nid` )
|
| 51 |
) TYPE = MYISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
|
| 52 |
|
| 53 |
3. Optionally configure the two variations of page language by visiting:
|
| 54 |
|
| 55 |
administer > settings > page_lang
|
| 56 |
|
| 57 |
4. The page language is ultimately set at the theme level. To let your PHPTemplate
|
| 58 |
based theme interact with this module, you need to add some code to the template.php
|
| 59 |
file that comes with your theme. If there is no template.php file, you can simply
|
| 60 |
use the one included with this download. Here is the code:
|
| 61 |
|
| 62 |
function _phptemplate_variables($hook, $vars) {
|
| 63 |
$vars = array();
|
| 64 |
if ($hook == 'page') {
|
| 65 |
|
| 66 |
// This is the only important line
|
| 67 |
$vars['language'] = page_lang_page_get_lang();
|
| 68 |
|
| 69 |
}
|
| 70 |
return $vars;
|
| 71 |
}
|
| 72 |
|
| 73 |
As you can see from the code comment, there is only one important line
|
| 74 |
of code:
|
| 75 |
|
| 76 |
$vars['language'] = page_lang_page_get_lang();
|
| 77 |
|
| 78 |
This line needs to be added to the 'page' hook of the _phptemplate_variables
|
| 79 |
function.
|
| 80 |
|
| 81 |
Alternately, you can call page_title_page_get_lang() from page.tpl.php
|
| 82 |
directly at the place where the lang tag is generated. Normaly is this:
|
| 83 |
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language ?>" xml:lang="<?php print $language ?>">
|