I want to display fields from the current node using a viewfield. The "display field" for those fields was not sufficient for me, especially the display formatters for repeating dates is very poor. So I created a view to display only those dates that start after midnight ("12AM today") or start in the past and are currently active (to date less than "now"). And for repeating dates I want to also display the next 4 upcoming dates.

But viewfield does not like "recursion" (even if there is no recursion), the Devel->Render-tab says. I am aware that recursion might be possible, but only if the output in the view renders the viewfield again.

A solution to solve this problem is to add an option to the viewfield to allow for recursion. This would make sense in some circumstances

Comments

keithm’s picture

Status: Active » Closed (works as designed)

This behavior is by design.

For better field formatting, you might consider writing a custom formatter. (See hook_field_formatter_info() to get started.) There is also a module that might help: http://drupal.org/project/custom_formatters.

Hope this helps.

Pepe Roni’s picture

Category: bug » feature
Status: Closed (works as designed) » Active

Changed this to a feature request: Can you provide a checkbox to the viewfield to allow for recursion in this viewfield?

Reason: I used complex views with Ajax pagers to page thru attached Images, Dates, display a calendar and so on. I have patched the original module to allow for recursion (in all viewfields :( )

keithm’s picture

There is a recent code change that loosened the restriction on recursion; see the discussion in #1181226: Remove viewfield_views_query_alter() function. It was committed yesterday so if you upgrade to the latest 7.x-2.x-dev you'll get it.

sun’s picture

keithm’s picture

@wbue: Is the current version 7.x-2.x-dev insufficient for your purposes? It wouldn't be particularly difficult to allow recursion per viewfield or viewfield/instance but I would like to know there's at least one use case for it :)

sun’s picture

This might work in the latest code already, but will ultimately be fixed with the patch in #1071212: Fix viewfield rendering

colan’s picture

Assigned: colan » Unassigned
Status: Closed (fixed) » Active
Issue tags: +D7 stable release blocker

@keithm: Here's a use case for recursion:

  1. I'm creating a hierarchical data structure, a book let's say.
  2. I don't want to use the Book module because it's got its own custom table instead of using Entity Reference.
  3. I add a parent node reference field, "Parent", to my new content type called "Section".
  4. I can display the table of contents with Views tree.
  5. When I click on a particular section, a top-level chapter, I end up on a node view page for the section I chose.
  6. I expect to see all subsections of the node in question, but only the current node is displayed.
  7. In order to display these child sections along with the node, I install Viewfield.
  8. I create a new view, "Subsections", that displays all nodes with a given parent node ID (passed in as an argument).
  9. I add a Viewfield field to my Section content type defined as the Subsections view, with the current node ID as the argument.
  10. Now when I look at a Section node, I see all subsections as well, including sub-subsections and sub-sub-subsections etc. because of recursion; each child node displayed in the parent node recursively because of Viewfield.

This recursion described in the last step will only work if it is unblocked. It's a very simple means by which to display entire subtrees. No coding should be required.

sun’s picture

@colan: It sounds to me that #1071212: Fix viewfield rendering should make that use-case work. Can you test the patch?

keithm’s picture

@colan: Viewfield has supported recursion for a long time. I myself have a site that uses viewfield to recursively list chapters and subsections in just the way you describe. It works fine for that. The current issue is concerned with the fact that Viewfield used to disallow the node containing the viewfield from being rendered at all in the viewfield output. In #1181226: Remove viewfield_views_query_alter() function we removed that restriction too, so as I said in #5, I'm not sure if there's still a problem any longer, and if so what the use case for it is.

colan’s picture

I'm actually still working in D6 for this stuff, but I'll try to quickly throw together what I need to test this in D7. Stand by...

keithm’s picture

#1181226: Remove viewfield_views_query_alter() function applies to both 6.x-2.x and 7.x-2.x but not 6.x-1.x.

sun’s picture

well, you could also do us a favor and test the 6.x-1.x to 6.x-2.x upgrade path ;) (of course, make sure to do a backup first)

colan’s picture

But it looks like I need to do this on D7, as there's no D6 patch for #1071212: Fix viewfield rendering? I'm running 6.x-2.x-dev now, and the recursion isn't showing up.

I'll have to get to the upgrade path checking later. sorry. :)

keithm’s picture

If you're running on the latest 6.x-2.x-dev and your particular recursion isn't producing expected results, we'd like to understand the specifics of your case. Can you do a little more digging or produce a test install that illustrates your problem?

Also, FWIW, in my experience it's important to make sure the views are correct. I have often had a wrong argument or filter cause viewfield to produce no results.

colan’s picture

I'll see what I can figure out.

colan’s picture

Assigned: Unassigned » colan
colan’s picture

Status: Active » Reviewed & tested by the community

Also, FWIW, in my experience it's important to make sure the views are correct. I have often had a wrong argument or filter cause viewfield to produce no results.

Thanks for that tip, as that was exactly the problem. I forgot to include the viewfield in the fields list. ;)

It's all good now. I suppose we can say that this is fixed in D6 at least? I didn't test the D7 version.

sun’s picture

Status: Reviewed & tested by the community » Fixed

Thanks! 6.x-2.x and 7.x-2.x are more or less the same right now.

Status: Fixed » Closed (fixed)
Issue tags: -D7 stable release blocker

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

Status: Active » Closed (fixed)