Download & Extend

Allow area handlers to override the page title when used in an empty area.

Project:Views
Version:8.x-3.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)
Issue tags:VDC

Issue Summary

Currently there is a custom area handler used for the empty text in #1806334: Convert the node listing at /node to Views. This should be an option on area handlers to override the title, if the view is empty.

I have code for this but it would be better to wait for #1807624: Saving and rendering in empty region for 'Global: unfiltered' text does not work to be committed, as it fixes the empty area handling. I will then re roll what I have for this.

Comments

#1

Title:Allow area handlers to override the page title when used in empty area.» Allow area handlers to override the page title when used in an empty area.

#2

For me it seems to make more sense to have an extra area handler which can override the title and one which can just display some custom text.

#3

Good idea. I'll modify it for that!

#4

Status:active» needs review
AttachmentSizeStatusTest resultOperations
1808542-4.patch1.88 KBIdlePASSED: [[SimpleTest]]: [MySQL] 2,838 pass(es).View details

#5

Status:needs review» needs work

+++ b/lib/Drupal/views/Plugin/views/area/Title.phpundefined
@@ -0,0 +1,49 @@
+  protected function defineOptions() {

Can haz commentz?

+++ b/lib/Drupal/views/Plugin/views/area/Title.phpundefined
@@ -0,0 +1,49 @@
+    if (!empty($this->options['title'])) {
+      $this->view->setTitle(filter_xss_admin($this->options['title']), PASS_THROUGH);

Does this support tokens? We might refer them in the form as well.

+++ b/lib/Drupal/views/Plugin/views/area/Title.phpundefined
@@ -0,0 +1,49 @@
+    return;

Just a nitpick: An empty string sounds helpful.

#6

Status:needs work» needs review

Thanks for the review. Comments added, render() now returns an empty string. I have also added a test for this.

I have created a new issue so we can move the token code into the AreaPluginBase class: #1808648: Move tokenization form code into AreaPluginBase and use that in this plugin.

AttachmentSizeStatusTest resultOperations
1808542-6.patch3.21 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,064 pass(es).View details

#7

+++ b/lib/Drupal/views/Tests/Handler/AreaTest.phpundefined
@@ -104,4 +104,30 @@ class AreaTest extends HandlerTestBase {
+    $view->initDisplay('page');

I thought we were switching to 'page_1' everywhere?

+++ b/lib/Drupal/views/Tests/Handler/AreaTest.phpundefined
@@ -104,4 +104,30 @@ class AreaTest extends HandlerTestBase {
+          'id' => 'title',
+          'table' => 'views',
+          'field' => 'title',
+          'admin_label' => '',
+          'label' => '',
+          'empty' => '0',
+          'title' => 'Overridden title',

This is indented too far.

#8

Indentation, schoolboy error.

When we commit #1793700: The wizard creates "page" as first display id even though the views UI itself creates page_1 I will post a new patch for testing with the 'page_1' display.

#9

ok, looks like it's in :)

AttachmentSizeStatusTest resultOperations
1808542-9.patch3.21 KBIdlePASSED: [[SimpleTest]]: [MySQL] 3,064 pass(es).View details

#10

Status:needs review» fixed

Committed!
http://drupalcode.org/project/views.git/commit/41bc6a3

#11

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here