In projects, we often have the need to hide the display title of a Panels page. Setting the Page Title to [No Title] has the unpleasant side effect of also removing the Window Title -- the title in the browser window; head_title in Drupal html vars -- thereby killing SEO. The solution below provides a separate field to set the Window Title in Panels, which will meet the stated use case as well as allowing users to configure different text for the Window Title, for example, if a condensed/shortened title is desired.

Tokens from contexts may be used to fill in the Window Title field, but you'll need to add a Global token context to replicate the default Drupal window title format.

This is somewhat of a follow-on from #1271682: Title type should have an option to hide the title in the html but expands on the use case.

Comments

acrollet’s picture

Status: Active » Needs review
StatusFileSize
new3.71 KB

patch attached for review.

Status: Needs review » Needs work

The last submitted patch, 1: panels-allow_users_control_window_title-2262173-1.patch, failed testing.

acrollet’s picture

Status: Needs work » Needs review
StatusFileSize
new3.71 KB

updated patch to apply to HEAD.

acrollet’s picture

Updated patch with slightly improved description text and support for panelized entities.

jwilson3’s picture

Issue summary: View changes
StatusFileSize
new24.41 KB

Cleaned up description and added an image screenshot of how this looks.

jwilson3’s picture

+++ b/panels.install
@@ -487,3 +499,26 @@ function panels_update_7303() {
+    $msg[] = t('Added panels_display.window_title column.');
+  }
+
+  if (empty($msg)) {
+    $msg[] = t('window_title column already present in the panels_display table.');
+  }
+}

The $msg string must be returned in the hook_update_N. Patch below fixes this.

jwilson3’s picture

StatusFileSize
new964 bytes

Forgot interdif from the above:

rodrigoaguilera’s picture

Status: Needs review » Reviewed & tested by the community

works great

damienmckenna’s picture

Status: Reviewed & tested by the community » Needs work

You aren't supposed to call the module's hook_schema() in an update script, so this needs to be improved.

jwilson3’s picture

+++ b/panels.install
@@ -487,3 +499,22 @@ function panels_update_7303() {
+  $schema = panels_schema_7();
+
+  // Add the window_title column to the display table.
+  $table = 'panels_display';
+  $field = 'window_title';
+  // Due to a previous failure, the column may already exist:
+  if (!db_field_exists($table, $field)) {
+    $spec = $schema[$table]['fields'][$field];
+    db_add_field($table, $field, $spec);
+    return t('Added panels_display.window_title column.');
+  }

@Adrian: is instantiating the schema strictly necessary to actually add the new column?

Here is another example in docs: https://www.drupal.org/node/150215

damienmckenna’s picture

Any reason to not just use Metatag, and maybe Metatag:Panels?

rodrigoaguilera’s picture

Metatag is not a very light module just for this purpose

damienmckenna’s picture

Maybe I'm over-simplying it by saying that if the site is public then you probably want the other meta tags thus Metatag would be worth adding, otherwise you wouldn't be worried about the page title?

joshmiller’s picture

This module here claims to do a decent job:

https://www.drupal.org/project/panel_variant_page_title

Josh

jwilson3’s picture

StatusFileSize
new4.04 KB

This is a reroll of #4 to make it apply after the recent Panels security release.

To address #9 and #10, this patch follows the same methodology used throughout the panels.install file. Other commits have made it into the codebase since this patch was written that do things exactly how this patch did it.

jwilson3’s picture

Status: Needs work » Needs review

Seems like a couple people are using this successfully so I'm marking it back to Needs Review, and here's hoping for a fast RTBC.

jwilson3’s picture

StatusFileSize
new4.42 KB
new1023 bytes

I rerolled the wrong patch (#4 instead of #6) (facepalm)

Here is a proper reroll of #6, with an interdiff against #15.

facine’s picture

I've rerolled #16 to works with the last dev version.

facine’s picture

I've rerolled #18 to works with the last stable version. (3.8)

japerry’s picture

Status: Needs review » Closed (outdated)

Drupal 7 is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.