| 1 |
********************************************************************
|
| 2 |
P A G E T I T L E M O D U L E
|
| 3 |
********************************************************************
|
| 4 |
Original Author: Robert Douglass
|
| 5 |
Current Maintainers: Nicholas Thompson and John Wilkins
|
| 6 |
|
| 7 |
********************************************************************
|
| 8 |
DESCRIPTION:
|
| 9 |
|
| 10 |
This module gives you control over the page title. It gives you the chance
|
| 11 |
to provide patterns for how the title should be structured, and on node
|
| 12 |
pages, gives you the chance to specify the page title rather than defaulting
|
| 13 |
to the node title.
|
| 14 |
|
| 15 |
********************************************************************
|
| 16 |
PERMISSIONS:
|
| 17 |
|
| 18 |
This module defines the "set page title" and "administer page titles"
|
| 19 |
permissions. The "set page title" permission determines whether a user will
|
| 20 |
be able to edit the "Page title" field on node edit forms (if visible.) The
|
| 21 |
"administer page titles" permission determines whether a user will be able to
|
| 22 |
edit the "Page title" administration pages.
|
| 23 |
|
| 24 |
********************************************************************
|
| 25 |
INSTALLATION:
|
| 26 |
|
| 27 |
1. Place the entire page_title directory into your Drupal modules/
|
| 28 |
directory or the sites modules directory (eg site/default/modules)
|
| 29 |
|
| 30 |
|
| 31 |
2. Enable this module by navigating to:
|
| 32 |
|
| 33 |
Administer > Build > Modules
|
| 34 |
|
| 35 |
At this point the Drupal install system will attempt to create the database
|
| 36 |
table page_title. You should see a message confirming success or
|
| 37 |
proclaiming failure. If the database table creation did not succeed,
|
| 38 |
you will need to manually add the following table definition to your
|
| 39 |
database:
|
| 40 |
|
| 41 |
CREATE TABLE `page_title` (
|
| 42 |
`nid` INT NOT NULL ,
|
| 43 |
`page_title` VARCHAR( 128 ) NOT NULL ,
|
| 44 |
PRIMARY KEY ( `nid` )
|
| 45 |
) /*!40100 DEFAULT CHARACTER SET utf8 */;
|
| 46 |
|
| 47 |
3. Optionally configure the two variations of page title by visiting:
|
| 48 |
|
| 49 |
Administer > Content management > Page titles
|
| 50 |
|
| 51 |
4. The page title is ultimately set at the theme level. To let your PHPTemplate
|
| 52 |
based theme interact with this module, you need to add some code to the template.php
|
| 53 |
file that comes with your theme. If there is no template.php file, you can simply
|
| 54 |
use the one included with this download. Here is the code:
|
| 55 |
|
| 56 |
function _phptemplate_variables($hook, $vars) {
|
| 57 |
$vars = array();
|
| 58 |
if ($hook == 'page') {
|
| 59 |
|
| 60 |
// These are the only important lines
|
| 61 |
if (module_exists('page_title')) {
|
| 62 |
$vars['head_title'] = page_title_page_get_title();
|
| 63 |
}
|
| 64 |
|
| 65 |
}
|
| 66 |
return $vars;
|
| 67 |
}
|
| 68 |
|
| 69 |
As you can see from the code comment, there are only three important lines
|
| 70 |
of code:
|
| 71 |
|
| 72 |
if (module_exists('page_title')) {
|
| 73 |
$vars['head_title'] = page_title_page_get_title();
|
| 74 |
}
|
| 75 |
|
| 76 |
These lines need to be added to the 'page' hook of the _phptemplate_variables
|
| 77 |
function.
|
| 78 |
|
| 79 |
Alternately, you can call page_title_page_get_title() from page.tpl.php
|
| 80 |
directly at the place where the title tag is generated.
|