Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.6
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
11 Jul 2009 at 02:20 UTC
Updated:
20 Jan 2010 at 02:07 UTC
Is it possible to nest views into each-other? say to create a view and then call that view in a different view?
Comments
Comment #1
merlinofchaos commentedYes, you'd have to embed the view in theme override. See the embedding and theming topics in the advanced help.
Comment #2
JirkaRybka commentedTo put two views into a single block, I just switched the footer text on one view to PHP-code input format, and called views_embed_view() from there. No need for theme overrides (this is content, not theming IMO).
Comment #3
boabjohn commentedJust chasing this concept a bit further, I'd like to *join* two views (since it appears that the term "nesting" used here is meant to be linking, or entraining?).
Usecase:
Display a Project's Milestones and each "Percent Complete" statement as reported each quarter.
Relationships:
A Project has Milestones (1:n)
Each Milestone has Perc Completes (quarterly statements of condition) (1:n)
So the two views are:
1. Milestones: print each milestone_title on a row, argument = Project ID
2. Percents: print each perc_title on a row, argument = Milestone ID
On the Project page, I want to call in a *joined* view to give this effect:
Milestone 1
--Perc Statement Q4-2009
--Perc Statement Q3-2009
--Perc Statement Q2-2009
--Perc Statement Q1-2009
--Perc Statement Q4-2008
--Perc Statement Q3-2008
Milestone 2
--Perc Statement Q4-2009
--Perc Statement Q3-2009
--Perc Statement Q2-2009
--Perc Statement Q1-2009
--Perc Statement Q4-2008
--Perc Statement Q3-2008
Is this a job for Views, or should I bail straight out to a custom module?
Thanks!
Comment #5
MBroberg commentedI did it like this:
1. Make the main view show fields from the percent data.
2. Create a relationship to the Milestone data and add that field to the view also.
Data will now output like this:
Milestone 1
Perc Statement Q4-2009
Milestone 1
Perc Statement Q3-2009
Milestone 1
Perc Statement Q2-2009
Milestone 1
Perc Statement Q1-2009
Milestone 1
Perc Statement Q4-2008
Milestone 1
Perc Statement Q3-2008
3. Now group by Milestone and exclude the field from display.
You can also use this trick to get other fields into the "group by" field if you rewrite the milestone output to include tokens.
For example, I have the following data:
Flag Football
Mission Viejo
Mondays
12:30 pm - 1:30 pm
* 10/5/09
* 10/12/09
* 10/19/09
* 10/26/09
Each line is a field but the dates are the only ones that are actually displayed in the view. The rest are excluded and their tokens are used in a rewrite of output for one field (doesn't really matter which one as long as it comes last in the field list) that is used as the "group by."