please forgive my poor english, I just want to report this bug.

I create a custom views style plugin, but it output blank.

then I try to find the reason, the bug in views.module file (about line 182~187)

I don't know why

before:

 if (isset($def['theme_file'])) {
        $include = \Drupal::root() . '/' . $module_dir. '/' . $def['theme_file'];
        if (is_file($include)) {
          require_once $include;
        }
      }

after:

 if (isset($def['theme_file'])) {
        $include = \Drupal::root() . '/' . $module_dir. '/' . $def['theme_file'];
        if (is_file($include)) {
          require_once $include;
        }
        $hooks[$def['theme']]['includes'][] = $module_dir . '/' . $def['theme_file'];
      }

As you can see, after I add this code :
$hooks[$def['theme']]['includes'][] = $module_dir . '/' . $def['theme_file'];

then it work well.

thanks.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Issue tags: +Needs tests

Could you please specify how we can reproduce the issue?

zhiqiang.qiu’s picture

My Drupal 8 custom module is like this:

---test.info.yml
---test.module
---test.theme.inc
---src(dir)
------Plugin(dir)
---------views(dir)
------------row(dir)
---------------testPluginRowFields.php
------------style(dir)
---------------testPluginStyleDefault.php
---template(dir)
-------test-view-unformatted.html.twig

so you should be know it's a views syle plugin. I just test drupal beta9, there is still have this bug.

thanks.

zhiqiang.qiu’s picture

step:
1. install my custom views style module.
2. create or modify any views.
3. change the Format Style to select my custom style.
4. you will found the ouput is blank

thanks.

dawehner’s picture

@zhiqiang.qiu
Do you want to try to write a patch for this, see https://www.drupal.org/node/707484

zhiqiang.qiu’s picture

this is the patch to fix this issue.
This is my first time to create a patch. if not right, please tell me. :)
thanks.

dawehner’s picture

Status: Active » Needs review

Looks great. Let's see what the testbot says about it.

zhiqiang.qiu’s picture

sorry, I just note Drupal8 will be released on November 19, 2015, I just hope Drupal8 is perfect, so I very hope this bug can be fixed. thanks.

Lendude’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/views.module
@@ -184,6 +184,7 @@ function views_theme($existing, $type, $theme, $path) {
+        $hooks[$def['theme']]['includes'][] = $module_dir . '/' . $def['theme_file'];

wouldn't it make more sense to put this inside the if(), no point adding the file to $hooks if it doesn't exist.

Also still needs tests so back to ' needs work'.

zhiqiang.qiu’s picture

Status: Needs work » Closed (works as designed)

sorry , maybe it's my mistake, I read this module code, then I found maybe I can write the "template_preprocess_example_view_fields" function in "test.module" file not in "test.theme.inc" file, and change views style plugin annotation :

remove this:

* module = "test",
* register_theme = TRUE,
* theme_file = "test.theme.inc",

then it works as designed.