"Exclude from display" doesn't allow for Replacement pattern

bgoodin - March 23, 2009 - 05:41
Project:Calendar
Version:6.x-2.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I have a field called field_event_date. I want to use it as a "Replacement token" in a "Output this field as a link". I run into two issues with this. First, if I do not click "Exclude from display" the value works as a "Replacement token" but is wrapped with span because of date.theme.

date.theme

function theme_date_display_combination($element) {
...
  elseif ($date1 == $date2 || empty($date2)) {
    $output .= '<span class="date-display-single">'. $date1 . $timezone .'</span>';
  }
}

Secondly, if I click the "Exclude from display" the "Replacement token" shows that I can use the hidden value in the "Output this field as a link". However, when I place the "Replacement token" of excluded token called [field_event_date_value] it is not available for use.

I have no idea what I'm missing. I just want to add a link that points to another view. But I can't because it doesn't seem like any of the "Output this field as a link" works correctly.

What am I missing?

#1

merlinofchaos - April 8, 2009 - 16:56
Status:active» postponed (maintainer needs more info)

What style plugin are you using? If it's not a Views core style, it's possible that the style plugin isn't rendering excluded fields after the 2.3 changes, and it needs to.

#2

bgoodin - April 16, 2009 - 00:03

Sorry for the delay. I have no idea what a style plugin is. Could you provide more detail on how i can answer your question?

I googled and found this http://drupal.org/node/193448. After searching for style_plugins in my project the only occurrences exist under the in the module/views directory.

An additional note. It seems that the theme is no longer wrapping the date when "Exclude from display" is unchecked. However, I still have an issue with the value being unavailable when I have "Exclude from display" checked. I am now using version 6.x-2.5.

#3

merlinofchaos - April 16, 2009 - 05:22

Style: i.e, table, unformatted, grid, list or something from another module (calendar, for example).

#4

bgoodin - April 20, 2009 - 03:55

Thanks for your continued insight. I am using the Calendar module.

Just to clarify, my only issue at this point is that the replacement token fails to produce output when it is set to "Exclude from display". I'd like to exclude the value from display yet use it as a value in the "Output this field as a link" value.

I have performed more debugging and found that in the view_handler_field.inc get_render_tokens() function the $handler->last_render is not set on the handler. This results in the field being set as an empty string ('').

     if (isset($handler->last_render)) {
        $tokens["[$field]"] = $handler->last_render;
      }
      else {
        $tokens["[$field]"] = '';
      }

I performed a search on my code base and found last_render is only ever called and set in the views_handler_field.inc. I'm going to continue debugging until i get to the bottom of this. If you could provide any hints as to why last_render would fail to get set I'd appreciate it.

Following is the full code I am referring to in the view_handler_field.inc

  function get_render_tokens() {
    $tokens = array();
    if (!empty($this->view->build_info['substitutions'])) {
      $tokens = $this->view->build_info['substitutions'];
    }
    $count = 0;
    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
      $token = '%' . ++$count;
      if (!isset($tokens[$token])) {
        $tokens[$token] = '';
      }
    }

    // Now add replacements for our fields.
    $options = array();
    foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
      if (isset($handler->last_render)) {
        $tokens["[$field]"] = $handler->last_render;
      }
      else {
        $tokens["[$field]"] = '';
      }
      // We only use fields up to (and including) this one.
      if ($field == $this->options['id']) {
        break;
      }
    }

    return $tokens;
  }

#5

bgoodin - April 23, 2009 - 18:40
Status:postponed (maintainer needs more info)» active

#6

agerson - June 5, 2009 - 16:42

I am having the same issue. Not sure if this belongs on the calendar or views queue.

http://drupal.org/node/442080

#7

merlinofchaos - June 12, 2009 - 16:24

If it works in Views core styles (table, fields) but not in calendar, then the place to look is calendar.

#8

agerson - June 14, 2009 - 06:25
Project:Views» Calendar
Version:6.x-2.3» 6.x-2.x-dev
Component:Views Data» Code
Category:support request» bug report

It works in other styles, just not in calendar.

#9

peted - June 25, 2009 - 09:20

Just add my experience here - have 'exclude from display' and 'rewrite output' working on other Views. When I set 'Exclude from Display" on the field that I have 'reproduced' in a later field, I lose sight of both the original and the replicated.
eg first example shows fields as basic fields

[title]
[field_event_dates_value]
[field_location_value]

this shows the Replacement patterns applied

[title] : [field_event_dates_value] : [field_location_value]

before I click exclude from display on the first two fields I get them repeated (so i know replacement is working fine) so I then see

[title]
[field_event_dates_value]
[title] : [field_event_dates_value] : [field_location_value]

when I set the first two fields to 'exclude from display' i just get

: : [field_location_value]

Hope the explanation helps with the debugging.

#10

peted - June 25, 2009 - 09:22

Guess I should add to above - this is in Calendar - on the Month View - using 6.2.2

#11

sime - June 30, 2009 - 00:54

The attached screenshots should identify the problem clearly, I hope.

source-field.jpg -- `source` field is rewritten.
amount-field.jpg -- `amount` field rewritten to include the `source` field.

output.jpg -- the amount field is actually using the rewritten source field, rather than the raw source field.

So, if I actually exclude the `source` field, it can't be used at all because its output is nothing.

AttachmentSize
source-field.jpg 71.41 KB
amount-field.jpg 59.33 KB
output.jpg 100.34 KB

#12

ultimike - July 2, 2009 - 22:09

I can also confirm that this appears to be an issue with the Calendar module. Here's how to quickly reproduce it:

1. Start with the default "calendar" view (make sure you have some nodes entered that show up on the calendar!).

2. Add the "Node: Nid" field to the "Defaults" display and check the "Exclude from display" box.

3. Reorder the fields so that "Node: Nid" is first.

3. Click to edit the "Node: Title" field and check the "Output this field as a link" box. Add a link path that utilizes the "[nid]" token (something like "event/[nid]").

4. Be sure the "Link this field to its node" box is unchecked.

5. Go and check out the display of the view (/calendar) - you'll see that the links for all of the node titles are missing the [nid].

I checked this in both 6.x-2.1 and 6x-2.x-dev with the same result.

For now, I'm able to get around it by keeping the "Exclude from display" box unchecked, and just hiding the Node ID via theming...

-mike

#13

refman1073 - July 10, 2009 - 22:33

I am having the same problem in the 6.x.2.1 code. The bug appears to be in file calendar/theme/theme.inc at around line 113. The original code

      if (!empty($field->options['exclude'])) {
        if (isset($items[$num]->{$field_alias})) unset($items[$num]->{$field_alias});
      }
      elseif (!empty($field) && is_object($field)) {
        // Theme the copy instead of the original row so duplicate date
        // fields each get a fresh copy of the original data to theme.
        $items[$num]->{$field_alias} = $field->theme($copy);
      }

Any excluded field is never rendered. Here is code that seems to work ....

      if (!empty($field) && is_object($field)) {
        // Theme the copy instead of the original row so duplicate date
        // fields each get a fresh copy of the original data to theme.
        $items[$num]->{$field_alias} = $field->theme($copy);
        if (!empty($field->options['exclude'])) {
          unset($items[$num]->{$field_alias});
        }
      }

#14

ecoluke - July 23, 2009 - 10:57

I have exactly the same problem.

Even worse, if you set the rewrite field option to something like <div class="i_will_get_rid_of_you_somehow">[token]</div> (there are so many things you can try and they all fail, but this one fails in the craziest way) then the output goes like this:

<div id="calendar:<div class=" class="calendar monthview" i_will_get_rid_of_you_somehow="">87</div>
:field_date:0:0">
<div id="nid" class="view-field view-data-nid">
<div class="view-label-nid">Nid</div>
<div class="i_will_get_rid_of_you_somehow">87</div>
</div>

...and that looks pretty crazy, let me tell you!

Something is pretty loose inside the whole exclude / rewrite in calendar view btlot.

#15

iva2k - August 7, 2009 - 07:13

This seems to be related to #382852: [Calendar Views] Replacement patterns don't work if referencing a field excluded from display.

I've posted a patch there (http://drupal.org/node/382852#comment-1878058) which fixes that problem. Can anyone check and report back if that patch fixes or affects this issue here?

#16

lsommerer - September 6, 2009 - 03:46

I'm using 6.x-2.x-dev and neither #14 nor #15 fixed this for me.

I'm seeing slightly different results than others seem to be seeing, but I am only seeing these results if the View Style is Calendar or Calendar Navigation:

If I add the field Node: Nid to a view, everything is displayed correctly.
If "Exclude from display" is set for Node: Nid then MOST of the nodes in the view are not displayed (one node per month is displayed)
If "Rewrite the output of this field" is instead set to a space for Node: Nid, then I get the exact same result (just testing)

Just trying to add a bit more information.

#17

NikLP - September 10, 2009 - 13:32

Same for me. If I set up a calendar so that I want to have all my fields rendered in one link, I can't. To get even close to this, I have to NOT exclude them from view at all, then have them in a not-preferable order, and be done with it. If the field is not to be rendered, that doesn't mean we don't want access to the "token" and use it in another field's display.

#18

pyzahl - September 16, 2009 - 03:40

I also reported this issue beginning of this year... same thing. Any fixes/patches?

#19

lsommerer - November 3, 2009 - 20:33

It looked to me like this might have been one of the issues fixed in Views 2.7, but no such luck.

 
 

Drupal is a registered trademark of Dries Buytaert.