Currently there is a custom area handler used for the empty text in #1806334: Replace the node listing at /node with a view. 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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

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.
dawehner’s picture

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.

damiankloip’s picture

Good idea. I'll modify it for that!

damiankloip’s picture

Status: Active » Needs review
FileSize
1.88 KB
dawehner’s picture

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.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
3.21 KB

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.

tim.plunkett’s picture

+++ 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.

damiankloip’s picture

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.

damiankloip’s picture

FileSize
3.21 KB

ok, looks like it's in :)

tim.plunkett’s picture

Status: Needs review » Fixed

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