Commit 2051d8c9 authored by stefan.r's avatar stefan.r

Issue #578400 by tbradbury, therealssj, joshi.rohit100, aaronschachter, Gábor...

Issue #578400 by tbradbury, therealssj, joshi.rohit100, aaronschachter, Gábor Hojtsy, hgoto, melsi, er.pushpinderrana, valthebald, mw4ll4c3, Damien Tournoud, idflood, makbul_khan8, sign, gvorbeck, amitgoyal, Sivaji, Cottser, dinarcon: Display the page title, even if "0"
parent 1ed47f05
......@@ -5,6 +5,7 @@ Drupal 7.51, xxxx-xx-xx (development version)
used as an admin theme.
- Exceptions thrown in dblog_watchdog() are now caught and ignored.
- Clarified the warning that appears when modules are missing or have moved.
- If the page title is "0", it is now displayed.
- Numerous small bugfixes.
- Numerous API documentation improvements.
......
......@@ -2596,9 +2596,10 @@ function template_preprocess_html(&$variables) {
}
// Construct page title.
if (drupal_get_title()) {
$title = drupal_get_title();
if (strlen(trim($title))) {
$head_title = array(
'title' => strip_tags(drupal_get_title()),
'title' => strip_tags($title),
'name' => check_plain(variable_get('site_name', 'Drupal')),
);
}
......@@ -2697,7 +2698,8 @@ function template_process_page(&$variables) {
$variables['breadcrumb'] = theme('breadcrumb', array('breadcrumb' => drupal_get_breadcrumb()));
}
if (!isset($variables['title'])) {
$variables['title'] = drupal_get_title();
$title = drupal_get_title();
$variables['title'] = strlen(trim($title)) ? $title : NULL;
}
// Generate messages last in order to capture as many as possible for the
......
......@@ -1943,6 +1943,32 @@ class NodeTitleTestCase extends DrupalWebTestCase {
// Test node title is clickable on teaser list (/node).
$this->drupalGet('node');
$this->clickLink($node->title);
// Test edge cases.
// When node title is set to 0, the title should be '0'.
$node = $this->drupalCreateNode(array('title' => '0'));
$this->drupalGet('node/' . $node->nid);
$this->assertTitle('0' . ' | Drupal', 'Page title is equal to 0.', 'Node');
// Test that 0 appears in the template <h1>.
$xpath = '//h1[@id="page-title"]';
$this->assertEqual(trim(current($this->xpath($xpath))),
'0',
'Node title is displayed as 0.',
'Node');
// When node title is empty string, the h1 doesn't show up.
$node = $this->drupalCreateNode(array('title' => ''));
$this->drupalGet('node/' . $node->nid);
$this->assertTitle('Drupal', '', 'Node');
$xpath = '//h1[@id="page-title"]';
$this->assertIdentical(count($this->xpath($xpath)), 0);
// When node title is string with only spaces, the h1 doesn't show up.
$node = $this->drupalCreateNode(array('title' => ' '));
$this->drupalGet('node/' . $node->nid);
$this->assertTitle('Drupal', '', 'Node');
$xpath = '//h1[@id="page-title"]';
$this->assertIdentical(count($this->xpath($xpath)), 0);
}
}
......
......@@ -86,7 +86,7 @@
<?php if ($site_name || $site_slogan): ?>
<div id="name-and-slogan">
<?php if ($site_name): ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<div id="site-name"><strong>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
</strong></div>
......@@ -126,7 +126,7 @@
<?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
<a id="main-content"></a>
<?php print render($title_prefix); ?>
<?php if ($title): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
<?php if (isset($title)): ?><h1 class="title" id="page-title"><?php print $title; ?></h1><?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($tabs): ?><div class="tabs"><?php print render($tabs); ?></div><?php endif; ?>
<?php print render($page['help']); ?>
......
......@@ -99,7 +99,7 @@
<div id="name-and-slogan"<?php if ($hide_site_name && $hide_site_slogan) { print ' class="element-invisible"'; } ?>>
<?php if ($site_name): ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<div id="site-name"<?php if ($hide_site_name) { print ' class="element-invisible"'; } ?>>
<strong>
<a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
......@@ -187,7 +187,7 @@
<?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>
<a id="main-content"></a>
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<h1 class="title" id="page-title">
<?php print $title; ?>
</h1>
......
......@@ -8,7 +8,7 @@
<div id="header">
<div id="logo-floater">
<?php if ($logo || $site_title): ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<div id="branding"><strong><a href="<?php print $front_page ?>">
<?php if ($logo): ?>
<img src="<?php print $logo ?>" alt="<?php print $site_name_and_slogan ?>" title="<?php print $site_name_and_slogan ?>" id="logo" />
......@@ -42,7 +42,7 @@
<a id="main-content"></a>
<?php if ($tabs): ?><div id="tabs-wrapper" class="clearfix"><?php endif; ?>
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<h1<?php print $tabs ? ' class="with-tabs"' : '' ?>><?php print $title ?></h1>
<?php endif; ?>
<?php print render($title_suffix); ?>
......
......@@ -2,7 +2,7 @@
<div id="branding" class="clearfix">
<?php print $breadcrumb; ?>
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php if (isset($title)): ?>
<h1 class="page-title"><?php print $title; ?></h1>
<?php endif; ?>
<?php print render($title_suffix); ?>
......
Markdown is supported
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