1

I'm trying to get a date from a node to a view pane. When someone is viewing the node, they should see a view on the right that is just a list of other nodes with the same day in the "event_date_time" field.

Here's screenshots of how everything is set up: http://imgur.com/a/eXCMA

1) First is the pane layout. The left is the node content with event_date_time. The right top is a view panel that has no filters, so you can see all the nodes and dates. Below it is the same view panel with a contextual filter.

2) the current results. You can see the right bottom only matches the two nodes that have the exact same year, month, day, hour and minutes.

3) the contextual filter setup. It's set with granularity of days, but doesn't seem to make any difference what granularity is set. Even if it is changed to "year", it still only returns the one exact matching item. If I change one of the two matching nodes from 4:00 to 4:15, they no longer match.

4) I'm asking for the date field from the Panel context in Views

5) And it's set up in Panels to send

6) The contextual filter returns the correct 4 events that match the day, if I manually pass it a YYYY-MM-DD format.

I looked through the context and relationship options in both panels and views and can't see any other way to send or format this date. I feel like I must be missing something basic in my understanding of how this is supposed to work.

(I get the same results whether I create the contextual filter using "Content: Event Date Time" or "Date: Date (node)", and whether they are set to "date range" or "only this field".)

This is Drupal 7.22, Panels & Views both current dev.

  • Please try creating a custom pane in Panels, find the token (keyword) that Panels uses to represent the time argument, and write it out in the pane. That way, you'll get to the the exact value Panels passes on to Views. Might be a start. (It's not a very elegant debugging method, but it's often been helpful for me) – Letharion Jul 22 '13 at 12:59
  • That's a good idea, so at least I know what I'm dealing with. The token is %node:field_event_date_time, and panels spits it out as "2013-07-31 16:00:00", which is what I would expect. Using that as a manual filter on the views preview interface gives the same (incorrect) results as the panes do. – Nathaniel Jul 22 '13 at 15:24
2

After struggling for some time, I've still not found any way that works via context from Panels. Other people have said Panels values were determined by the "token" content display mode, but that isn't the case, at least with dates. Of course you can put the value in the URL and have Views grab it there, but for my use that wasn't appropriate. It also seems more fragile since it makes all content dependent on the path structure.

The best option I found was setting the "Argument Input" on the View to "Input on Pane Config". Then in the Panel Pane, use keyword/token substitution. I created a custom date & time formatter that is CCYY-MM-DD, called "date only", and set the Panel option to "%node:field-my-date-field:value:date_only". That grabs just the first value from a date range. For a field without range, "%node:field-my-date-field:date_only" works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.