Commit b50ea16c authored by Nicholas Thompson's avatar Nicholas Thompson
Browse files

Added blog scope for page titles. Also added a Token Scope column to the admin page

parent 4bf5e734
......@@ -11,6 +11,7 @@ foreach (element_children($form['pattern']) as $key) {
$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']) : '',
);
......@@ -18,6 +19,6 @@ foreach (element_children($form['pattern']) as $key) {
$rows[] = $row;
}
print theme('table', array(t('Page Type'), t('Pattern'), t('Show Field')), $rows);
print theme('table', array(t('Page Type'), t('Token Scope'), t('Pattern'), t('Show Field')), $rows);
print drupal_render($form);
......@@ -34,6 +34,12 @@ function page_title_admin_settings() {
);
$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(
'page_title_default' => array(
......@@ -73,6 +79,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'),);
}
......@@ -92,7 +100,20 @@ 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'),);
}
......
......@@ -19,7 +19,7 @@ function page_title_help($path, $arg) {
$output = NULL;
switch ($path) {
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>';
......@@ -255,8 +255,8 @@ function page_title_get_title() {
$title = check_plain(strip_tags($node->page_title));
}
}
// If we're looking at a user profile page, get the user title
elseif (arg(0) == 'user' && is_numeric(arg(1))) {
// If we're looking at either a user profile page or a users blog page, get the user title
elseif ((arg(0) == 'user' || arg(0) == 'blog') && is_numeric(arg(1))) {
if (variable_get('page_title_user_showfield', 0) && ($user_title = page_title_load_title(arg(1), 'user'))) {
$title = check_plain(strip_tags($user_title));
}
......@@ -377,6 +377,11 @@ 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)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment