content hierarchy, two columns. grandchild nodes?
Hello,
I'm currently building a lyrics site and I'm planning out the content structure.
I have three node types with the following node hierarchy:
artist -> album -> song
On the artist page, I'm trying to display two columns: a list of all the artist's songs and a list of their albums (that link to individual songs). Here's a mock-up of what I'm attempting.
http://www.massgames.biz/images/artist_page_mockup.gif
I'm having a hard time figuring out how to accomplish this. Right now I'm using node hierarchy and displaying all child nodes.
I feel like this can be done with views, however my knowledge is still a bit shaky. The song nodes are "trapped" under the album nodes. I'm basically trying to display the "grandchild" nodes of artists.
Is this possible? Any help would be awesome. I've been doing a lot of reading and I just need a general starting point to figure things out.

_
I would definitely do this with nodereference fields and views-- you can get quite complex in the hierarchy but you can access the entire tree quite easily with views using 'relationships'. See views advanced help, the screencast at http://drupal.org/node/248766, and http://gotdrupal.com/videos/drupal-views-relationships for more info.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Thanks so much. I'll take a
Thanks so much. I'll take a look at the screencasts and hopefully I can figure it out.
Ok, unfortunately after many
Ok, unfortunately after many hours I haven't been able to get this working.
I've figured out node reference and how to establish relationships between content types. However with views, my question is: If I'd like to display a list of all 'albums' of an 'artist' on every artist page... that requires an argument (along with a relationship), right?
It seems to be dynamic content that functions for any album of any artist. Unlike many of the example screencasts I've seen, this view seems to be saying 'for any page of this type, display this content if it has this relationship.'
I'm just completely clueless as how to accomplish this.
Since there will eventually be hundreds of artists, can I accomplish this with only one view? How do I tell views to display this content for every content type 'artist'?
_
It took me a bit to grasp relationships and arguments (i ended up watching the videos several times), but yes that's how you do it. And using arguments, you only need one view no matter how many artists you have-- that's exactly what they're for.
Adding a relationship for album to an artist view allows you to access and display the album fields on an artist based view. You might also want to checkout the views_attach module to actually add the view of the albums right to the artist page.
Also see the http://www.lullabot.com/articles/photo-galleries-views-attach screencast-- though it's talking about images and galleries it's just as applicable to albums ('images') and artists ('galleries').
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
Awesome, thanks again. I
Awesome, thanks again. I think views_attach is just what I need. I can tell I'm very close...
I've been trying to get the correct view to display 'albums' on artist pages, however something is off. Basically I have node type 'album' as a filter with node title as a field. I have the content:artist as a relationship. At this point it displays all albums when I run a preview.
But when I add an argument, nothing displays. I've basically been doing a trial and error, testing different variables with no luck. I had assumed I'd need to enter a node type:album as an input for it to work, but I'm not sure at this point.
This is what my view looks like. I feel like it's not long enough to be right! If anyone can see a glaring problem, it would be great if you could let me know.
- - - - - - - - - - - - - - - - - - - - -
SELECT node.nid AS nid,
node.title AS node_title
FROM node node
LEFT JOIN content_field_artist node_data_field_artist ON node.vid = node_data_field_artist.vid
INNER JOIN node node_node_data_field_artist ON node_data_field_artist.field_artist_nid = node_node_data_field_artist.nid
WHERE (node.status <> 0) AND (node.type in ('album')) AND (node.title = 'content')
ORDER BY node_title ASC
- - - - - - - - - - - - - - - - - - - - -
_
What is the exact argument you added? Also, post an export of the view (surrounded by <code> tags)-- it's much more useful to troubleshooting than the query.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.
The argument I added is an
The argument I added is an (Album)Node:Type. I'm not sure if this is incorrect or just isn't set up properly. In any case, here's the view export.
$view = new view;$view->name = 'Albums';
$view->description = 'Displays albums';
$view->tag = 'albums';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
'field_album_nid' => array(
'label' => 'Album',
'required' => 0,
'delta' => -1,
'id' => 'field_album_nid',
'table' => 'node_data_field_album',
'field' => 'field_album_nid',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('fields', array(
'title' => array(
'label' => 'Title',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'link_class' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'target' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'empty' => '',
'hide_empty' => 0,
'empty_zero' => 0,
'link_to_node' => 1,
'exclude' => 0,
'id' => 'title',
'table' => 'node',
'field' => 'title',
'relationship' => 'none',
),
));
$handler->override_option('sorts', array(
'title' => array(
'order' => 'ASC',
'id' => 'title',
'table' => 'node',
'field' => 'title',
'override' => array(
'button' => 'Override',
),
'relationship' => 'none',
),
));
$handler->override_option('arguments', array(
'type' => array(
'default_action' => 'not found',
'style_plugin' => 'default_summary',
'style_options' => array(),
'wildcard' => 'all',
'wildcard_substitution' => 'All',
'title' => 'Album name',
'breadcrumb' => 'Album name',
'default_argument_type' => 'fixed',
'default_argument' => '',
'validate_type' => 'node',
'validate_fail' => 'not found',
'id' => 'type',
'table' => 'node',
'field' => 'type',
'validate_user_argument_type' => 'uid',
'validate_user_roles' => array(
'2' => 0,
),
'relationship' => 'field_album_nid',
'default_options_div_prefix' => '',
'default_argument_user' => 0,
'default_argument_fixed' => '',
'default_argument_php' => '',
'validate_argument_node_type' => array(
'artist' => 'artist',
'album' => 0,
'letter' => 0,
'page' => 0,
'song' => 0,
'story' => 0,
),
'validate_argument_node_access' => 0,
'validate_argument_nid_type' => 'nid',
'validate_argument_vocabulary' => array(),
'validate_argument_type' => 'tid',
'validate_argument_transform' => 0,
'validate_user_restrict_roles' => 0,
'validate_argument_php' => '',
'override' => array(
'button' => 'Override',
),
),
));
$handler->override_option('filters', array(
'status' => array(
'operator' => '=',
'value' => '1',
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'status',
'table' => 'node',
'field' => 'status',
'relationship' => 'none',
),
'type' => array(
'operator' => 'in',
'value' => array(
'album' => 'album',
),
'group' => '0',
'exposed' => FALSE,
'expose' => array(
'operator' => FALSE,
'label' => '',
),
'id' => 'type',
'table' => 'node',
'field' => 'type',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler->override_option('cache', array(
'type' => 'none',
));
$handler->override_option('title', 'Albums:');
$handler->override_option('style_plugin', 'list');
$handler = $view->new_display('node_content', 'Node content', 'node_content_1');
$handler->override_option('style_plugin', 'default');
$handler->override_option('style_options', array(
'grouping' => '',
));
$handler->override_option('types', array(
'artist' => 'artist',
));
$handler->override_option('modes', array(
'0' => 'full',
));
$handler->override_option('argument_mode', 'none');
$handler->override_option('show_title', 1);
_
ah ok. The album type filter should be correct, but the argument is not. You need to remove the existing argument, and add one for the cck field that stores the artist reference and select the 'node from url' argument option. I think that should do the trick (assuming you're displaying the albums on the artist page). You can test it in the views preview by providing an artist argument in the arguments text box.
_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.