Posted by damiankloip on October 10, 2012 at 12:19pm
4 followers
| 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
#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
#5
+++ 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
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.
#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 :)
#10
Committed!
http://drupalcode.org/project/views.git/commit/41bc6a3
#11
Automatically closed -- issue fixed for 2 weeks with no activity.