Skip to content
Snippets Groups Projects
Commit 7d240fb8 authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Brought features inline with DRUPAL-6--2... Page number appending pattern,...

Brought features inline with DRUPAL-6--2... Page number appending pattern, blog homepage patterns, etc
parent 4422a526
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,12 @@ function page_title_admin_settings() {
'#theme' => 'page_title_admin_settings_patterns'
);
// Define the basic scope column values
$form['patterns']['scope'] = array(
'page_title_default' => array('#type' => 'markup', '#value' => t('Global Only'),),
'page_title_front' => array('#type' => 'markup', '#value' => t('Global Only'),),
'page_title_user' => array('#type' => 'markup', '#value' => t('User'),),
);
// Define the 'default' token patterns
$form['patterns']['pattern'] = array(
......@@ -74,6 +80,8 @@ function page_title_admin_settings() {
$form['patterns']['showfield'][$key .'_showfield'] = array(
'#default_value' => variable_get($key .'_showfield', 0),
) + $showfield_form_element;
$form['patterns']['scope'][$key] = array('#type' => 'markup', '#value' => t('Node'),);
}
......@@ -93,9 +101,29 @@ function page_title_admin_settings() {
$form['patterns']['showfield'][$key .'_showfield'] = array(
'#default_value' => variable_get($key .'_showfield', 0),
) + $showfield_form_element;
$form['patterns']['scope'][$key] = array('#type' => 'markup', '#value' => t('Taxonomy'),);
}
}
// Add the blog homepage pattern field
if (module_exists('blog')) {
$key = 'page_title_blog';
$form['patterns']['pattern'][$key] = array(
'#title' => t('Blog Homepage'),
'#default_value' => variable_get($key, ''),
) + $pattern_form_element;
$form['patterns']['scope'][$key] = array('#type' => 'markup', '#value' => t('User'),);
}
// Define the page pattern text field. This is appended to any page requests containing 'page=[0-9]+' in the query string
$form['page_title_pager_pattern'] = array(
'#type' => 'textfield',
'#title' => t('Pattern for pages that contain a pager'),
'#default_value' => variable_get('page_title_pager_pattern', ''),
'#description' => t('This pattern will be appended to a page title for any given page with a pager on it'),
);
// Add the token help to a collapsed fieldset at the end of the configuration page.
$form['token_help'] = array(
......@@ -130,6 +158,7 @@ function theme_page_title_admin_settings_patterns($form) {
$row = array(
drupal_render($title),
drupal_render($form['scope'][$key]),
drupal_render($form['pattern'][$key]),
isset($form['showfield'][$key .'_showfield']) ? drupal_render($form['showfield'][$key .'_showfield']) : '',
);
......@@ -137,7 +166,7 @@ function theme_page_title_admin_settings_patterns($form) {
$rows[] = $row;
}
return theme('table', array(t('Page Type'), t('Pattern'), t('Show Field')), $rows);
return theme('table', array(t('Page Type'), t('Token Scope'), t('Pattern'), t('Show Field')), $rows);
}
......
......@@ -18,7 +18,7 @@ function page_title_help($section) {
$output = NULL;
switch ($section) {
case 'admin/content/page_title':
$output = '<p>'. t('Page Title provides control over the &lt;title> element on a page using token patterns and an optional textfield to override the title of the item (be it a node, term, user or other). You can configure these settings below. Please click on the <strong><em>more help&hellip;</em></strong> link below if you need further assistance.') .'</p>';
$output = '<p>'. t('Page Title provides control over the &lt;title> element on a page using token patterns and an optional textfield to override the title of the item (be it a node, term, user or other). The Token Scope column lets you know which tokens are available for this field (Global is always available). Please click on the <strong><em>more help&hellip;</em></strong> link below if you need further assistance.') .'</p>';
break;
case 'admin/help#page_title':
$output = '<p>'. t('Drupal\'s default page title follows one of two patterns:') .'</p>';
......@@ -342,6 +342,9 @@ function page_title_page_get_title() {
$page_title_pattern = variable_get('page_title_default', '[page-title] | [site-slogan]');
}
// Append the pattern for pages with a pager on them
$page_title_pattern .= isset($_REQUEST['page']) ? variable_get('page_title_pager_pattern', '') : '';
$title = token_replace($page_title_pattern);
}
// Otherwise this is a non-frontpage page title.
......@@ -367,12 +370,20 @@ function page_title_page_get_title() {
$types['user'] = user_load(array('uid' => arg(1)));
$page_title_pattern = variable_get('page_title_user', '');
}
// Blog
elseif (arg(0) == 'blog' && is_numeric(arg(1))) {
$types['user'] = user_load(array('uid' => arg(1)));
$page_title_pattern = variable_get('page_title_blog', '');
}
// If pattern is emtpy (either if the type is not overridable or simply not set) fallback to the default pattern)
if (empty($page_title_pattern)) {
$page_title_pattern = variable_get('page_title_default', '[page-title] | [site-name]');
}
// Append the pattern for pages with a pager on them
$page_title_pattern .= isset($_REQUEST['page']) ? variable_get('page_title_pager_pattern', '') : '';
// Apply token patterns using token_replace_multiple
$title = token_replace_multiple($page_title_pattern, $types);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment