Hello,

Please correct me if I'm wrong: You can't preprocess views fields with 'group multiple values' enabled?

That is my issue at the moment. I want to use it to set up a dynamic block display: #830622: Views field with 'group multiple values' does not work

Thanks.
Danny

Comments

dawehner’s picture

This is not so nice solved currently. But you could write a style plugin which changes this behavior.

Currently every grouped content is added after the other

  function render() {
    if ($this->uses_row_plugin() && empty($this->row_plugin)) {
      vpr('views_plugin_style_default: Missing row plugin');
      return;
    }

    // Group the rows according to the grouping field, if specified.
    $sets = $this->render_grouping($this->view->result, $this->options['grouping']);

    // Render each group separately and concatenate.  Plugins may override this
    // method if they wish some other way of handling grouping.
    $output = '';
    foreach ($sets as $title => $records) {
      if ($this->uses_row_plugin()) {
        $rows = array();
        foreach ($records as $row_index => $row) {
          $this->view->row_index = $row_index;
          $rows[] = $this->row_plugin->render($row);
        }
      }
      else {
        $rows = $records;
      }

      $output .= theme($this->theme_functions(), $this->view, $this->options, $rows, $title);
    }
    unset($this->view->row_index);
    return $output;
  }
danny_joris’s picture

Thanks ! I appreciate yours & Earl's quick and helpful responses a lot ! :)

dawehner’s picture

Component: fieldapi data » Code

So this is fixed? I don't think so

For me this is a feature request / support request but no bug issue.

Letharion’s picture

Category: bug » support
Status: Active » Fixed

I take it Danny was satisfied with the answer "It doesn't work".

Status: Fixed » Closed (fixed)

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

jfarry’s picture

Just in case anyone else comes across this thread in desperation, the solution i used is the simplehtmldom API module: http://drupal.org/project/simplehtmldom

You can use this on the $output variable (which is in the tpl.php file or the particular row you're working with in Views) and manipulate it in a more simple way, instead of using multiple regular expression pattern replacements etc.

As an example, I wanted my outputted fields to just have class names, which were the same as the content in the field. I achieve this with this little piece of code:

    $html_obj = new simple_html_dom();

    // Create DOM from string
    $html_obj->load($output);
  
    foreach ($html_obj->find('div') as $container ){
      $newClass = strtolower($container->innertext);
      $container->class = $newClass;
    }
    

  
    print $html_obj;

I hope this helps someone else. I spent hours trying to find the particular preprocess function in views (that i'm not sure exists, lol) and I don't think a style plugin would have worked in my case. This was the next best thing :)